[tool] Use 'flutter pub get' for Flutter packages (#4397)

Extracts common logic for running `pub get`, and switches commands to use it. The common logic always uses `flutter pub get` for Flutter packages, rather than `dart pub get`, since the latter will fail if someone has a non-Flutter `dart` in their path before `flutter` (e.g., Dart team members contributing PRs).
This commit is contained in:
stuartmorgan
2023-07-07 16:22:19 -04:00
committed by GitHub
parent 958750d1fa
commit 12ec9fe3f0
11 changed files with 179 additions and 52 deletions

View File

@ -14,6 +14,7 @@ import 'package:yaml_edit/yaml_edit.dart';
import 'common/core.dart';
import 'common/package_looping_command.dart';
import 'common/process_runner.dart';
import 'common/pub_utils.dart';
import 'common/repository_package.dart';
/// A command to update .md code excerpts from code files.
@ -81,10 +82,7 @@ class UpdateExcerptsCommand extends PackageLoopingCommand {
try {
// Ensure that dependencies are available.
final int pubGetExitCode = await processRunner.runAndStream(
'dart', <String>['pub', 'get'],
workingDir: example.directory);
if (pubGetExitCode != 0) {
if (!await runPubGet(example, processRunner, platform)) {
return PackageResult.fail(
<String>['Unable to get script dependencies']);
}