resolveLocalIdeRoot function

String resolveLocalIdeRoot(
  1. String? pathArg
)

Resolves the local IDE root from an optional pathArg, expanding ~ and making it absolute against the current directory.

Implementation

String resolveLocalIdeRoot(String? pathArg) {
  if (pathArg == null || pathArg.isEmpty || pathArg == '.') {
    return p.normalize(Directory.current.path);
  }
  var path = pathArg;
  if (path == '~' || path.startsWith('~/')) {
    final home =
        Platform.environment['HOME'] ?? Platform.environment['USERPROFILE'];
    if (home != null) {
      path = path == '~' ? home : p.join(home, path.substring(2));
    }
  }
  return p.normalize(p.absolute(path));
}