resolveCliInstallation function
The installation the running CLI belongs to.
Only the Dart VM runs the CLI from a script, so any other executable is a
native build. A dart pub global activate snapshot lives under
_pubGlobalPackagesDir; any other script is a source checkout.
Implementation
CliInstallation resolveCliInstallation({
required final String resolvedExecutable,
required final String scriptPath,
}) {
if (p.basenameWithoutExtension(resolvedExecutable) != _dartExecutable) {
return CliInstallation.native;
}
if (p.split(scriptPath).contains(_pubGlobalPackagesDir)) {
return CliInstallation.pubGlobal;
}
return CliInstallation.source;
}