runPub method Null safety
Runs the 'dart pub' command with the given arguments.
By default stdout and stderr are sent to the console.
Pass in progress
to control the output.
If nothrow
== true (defaults to false) then if the
call to pub get fails an exit code will be returned in the
Progress rather than throwing an exception.
Implementation
Progress runPub({
required List<String> args,
String? workingDirectory,
Progress? progress,
bool nothrow = false,
}) {
progress ??= Progress.print();
if (useDartCommand) {
if (pathToDartExe == null) {
throw DCliException(
"Unable to run 'dart pub' as the dart exe is not on your path",
);
}
startFromArgs(
pathToDartExe!,
['pub', ...args],
nothrow: nothrow,
progress: progress,
workingDirectory: workingDirectory,
extensionSearch: false,
);
} else {
if (pathToPubExe == null) {
throw DCliException(
"Unable to run 'pub' as the pub exe is not on your path",
);
}
startFromArgs(
pathToPubExe!,
args,
nothrow: nothrow,
progress: progress,
workingDirectory: workingDirectory,
extensionSearch: false,
);
}
verbose(() => 'dart pub ${args.toList().join(' ')} finished.');
return progress;
}