@@ -91,12 +91,12 @@ Future<void> main(List<String> arguments) async {
9191 pubEnvironment['PUB_CACHE' ] = pubCachePath;
9292 }
9393
94- final String pubExecutable = '$flutterRoot /bin/cache/dart-sdk/bin/pub ' ;
94+ final String dartExecutable = '$flutterRoot /bin/cache/dart-sdk/bin/dart ' ;
9595
9696 // Run pub.
97- ProcessWrapper process = ProcessWrapper (await Process . start (
98- pubExecutable ,
99- < String > ['get' ],
97+ ProcessWrapper process = ProcessWrapper (await runPubProcess (
98+ dartBinaryPath : dartExecutable ,
99+ arguments : < String > ['get' ],
100100 workingDirectory: kDocsRoot,
101101 environment: pubEnvironment,
102102 ));
@@ -120,8 +120,9 @@ Future<void> main(List<String> arguments) async {
120120
121121 // Verify which version of snippets and dartdoc we're using.
122122 final ProcessResult snippetsResult = Process .runSync (
123- pubExecutable ,
123+ dartExecutable ,
124124 < String > [
125+ 'pub' ,
125126 'global' ,
126127 'list' ,
127128 ],
@@ -216,11 +217,11 @@ Future<void> main(List<String> arguments) async {
216217 ];
217218
218219 String quote (String arg) => arg.contains (' ' ) ? "'$arg '" : arg;
219- print ('Executing: (cd $kDocsRoot ; $pubExecutable ${dartdocArgs .map <String >(quote ).join (' ' )})' );
220+ print ('Executing: (cd $kDocsRoot ; $dartExecutable ${dartdocArgs .map <String >(quote ).join (' ' )})' );
220221
221- process = ProcessWrapper (await Process . start (
222- pubExecutable ,
223- dartdocArgs,
222+ process = ProcessWrapper (await runPubProcess (
223+ dartBinaryPath : dartExecutable ,
224+ arguments : dartdocArgs,
224225 workingDirectory: kDocsRoot,
225226 environment: pubEnvironment,
226227 ));
@@ -464,7 +465,6 @@ void putRedirectInOldIndexLocation() {
464465 File ('$kPublishRoot /flutter/index.html' ).writeAsStringSync (metaTag);
465466}
466467
467-
468468void writeSnippetsIndexFile () {
469469 final Directory snippetsDir = Directory (path.join (kPublishRoot, 'snippets' ));
470470 if (snippetsDir.existsSync ()) {
@@ -531,3 +531,18 @@ void printStream(Stream<List<int>> stream, { String prefix = '', List<Pattern> f
531531 print ('$prefix $line ' .trim ());
532532 });
533533}
534+
535+ Future <Process > runPubProcess ({
536+ required String dartBinaryPath,
537+ required List <String > arguments,
538+ String ? workingDirectory,
539+ Map <String , String >? environment,
540+ @visibleForTesting
541+ ProcessManager processManager = const LocalProcessManager (),
542+ }) {
543+ return processManager.start (
544+ < Object > [dartBinaryPath, 'pub' , ...arguments],
545+ workingDirectory: workingDirectory,
546+ environment: environment,
547+ );
548+ }
0 commit comments