current property

DartProject current

Returns the instance of the currently running DartProject.

If you call this method from a non-compiled script then we start the search from the scripts directory and search up the directory tree.

If you call this method from a compiled script then we will return the current working directory as there is no 'project root' for a compiled script.

Implementation

// ignore: prefer_constructors_over_static_methods
static DartProject get current {
  final script = Script.current;
  var startFrom = '.';
  if (!script.isCompiled) {
    startFrom = script.pathToScript;
  }
  return _current ??= DartProject.fromPath(startFrom, search: true);
}