runDartPubGet method
Runs dart pub get in the projectDirectory.
Throws a StateError (including the pub output) if it fails.
Implementation
Future<bool> runDartPubGet() async {
var workingDir = await projectDirectory;
// `catchOutput` drains the process output: an undrained `pub get` that
// prints more than the OS pipe buffer would never exit.
var processInfo = await runProcess(
'dart',
['pub', 'get'],
workingDirectory: workingDir.path,
catchOutput: true,
);
var ok = await processInfo.checkExitCode();
if (!ok) {
var output = '${processInfo.output}\n${processInfo.errorOutput}'.trim();
throw StateError('Error running: dart pub get > $processInfo\n$output');
}
return ok;
}