Skip to content

Commit

Permalink
Merge pull request #261 from Workiva/dart-pub-get
Browse files Browse the repository at this point in the history
Update `pub get` commands to `dart pub get`
  • Loading branch information
rmconsole7-wk authored Oct 27, 2023
2 parents eba07d3 + ebfd63c commit e599600
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/src/util/package_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,37 @@ Future<void> runPubGetIfNeeded(String packageRoot) async {
await runPubGet(packageRoot);
} else {
_logger.info(
'Skipping `pub get`, which has already been run, in `$packageRoot`');
'Skipping `dart pub get`, which has already been run, in `$packageRoot`');
}
}

/// Runs `pub get` in [workingDirectory], and throws if the command completed
/// with a non-zero exit code.
/// Runs `dart pub get` in [workingDirectory], and throws if the command
/// completed with a non-zero exit code.
///
/// For convenience, tries running with `pub get --offline` if `pub get` fails,
/// for a better experience when not authenticated to private pub servers.
/// For convenience, tries running with `dart pub get --offline` if `pub get`
/// fails, for a better experience when not authenticated to private pub servers.
Future<void> runPubGet(String workingDirectory) async {
_logger.info('Running `pub get` in `$workingDirectory`...');
_logger.info('Running `dart pub get` in `$workingDirectory`...');

final process = await Process.start('pub', ['get'],
final process = await Process.start('dart', ['pub', 'get'],
workingDirectory: workingDirectory,
runInShell: true,
mode: ProcessStartMode.inheritStdio);
final exitCode = await process.exitCode;

if (exitCode == 69) {
_logger.info(
'Re-running `pub get` but with `--offline`, to hopefully fix the above error.');
final process = await Process.start('pub', ['get', '--offline'],
'Re-running `dart pub get` but with `--offline`, to hopefully fix the above error.');
final process = await Process.start('dart', ['pub', 'get', '--offline'],
workingDirectory: workingDirectory,
runInShell: true,
mode: ProcessStartMode.inheritStdio);
final exitCode = await process.exitCode;
if (exitCode != 0) {
throw Exception('pub get failed with exit code: $exitCode');
throw Exception('dart pub get failed with exit code: $exitCode');
}
} else if (exitCode != 0) {
throw Exception('pub get failed with exit code: $exitCode');
throw Exception('dart pub get failed with exit code: $exitCode');
}
}

Expand Down

0 comments on commit e599600

Please sign in to comment.