getWorkspaceRootPath method
Get the workspace root path (only if isWorkspace or hasWorkspaceResolution)
Implementation
Future<String> getWorkspaceRootPath() async {
if (isWorkspace) {
return path;
} else {
var parent = normalize(absolute(path));
while (true) {
var newParent = dirname(parent);
if (newParent == parent) {
break;
}
parent = newParent;
if (isPubPackageRootSync(parent)) {
var pubspecYaml = await pathGetPubspecYamlMap(parent);
if (pubspecYamlIsWorkspaceRoot(pubspecYaml)) {
return parent;
}
}
}
}
throw 'No workspace root found';
}