Use .pub-cache from Flutter root, if it exists. (#13358)
The purpose of this PR is to make it so that when the user runs 'flutter', if they have a .pub-cache directory in their flutter root, we use that instead of the default location for the pub cache. Otherwise, it should act as before. The eventual goal is to support a pre-populated flutter .zip/.tar.gz file that has everything the developer needs in one bundle. In order for that to actually work, we need to have the pub cache be self-contained, and not in the user's home dir. Another advantage of this is that if you have multiple flutter repos that you're switching between, then the versions in the pub cache will remain static when you switch between them. This is an attempt to re-land: #13248. Includes a fix for the test that makes it work on bots in the presence of PUB_CACHE being set, and no other changes.
This commit is contained in:
@@ -65,14 +65,25 @@ dependencies:
|
||||
}
|
||||
new File('dev/docs/lib/temp_doc.dart').writeAsStringSync(contents.toString());
|
||||
|
||||
final String flutterRoot = Directory.current.path;
|
||||
final Map<String, String> pubEnvironment = <String, String>{
|
||||
'FLUTTER_ROOT': flutterRoot,
|
||||
};
|
||||
|
||||
// If there's a .pub-cache dir in the flutter root, use that.
|
||||
final String pubCachePath = '$flutterRoot/.pub-cache';
|
||||
if (new Directory(pubCachePath).existsSync()) {
|
||||
pubEnvironment['PUB_CACHE'] = pubCachePath;
|
||||
}
|
||||
|
||||
final String pubExecutable = '$flutterRoot/bin/cache/dart-sdk/bin/pub';
|
||||
|
||||
// Run pub.
|
||||
Process process = await Process.start(
|
||||
'../../bin/cache/dart-sdk/bin/pub',
|
||||
pubExecutable,
|
||||
<String>['get'],
|
||||
workingDirectory: 'dev/docs',
|
||||
environment: <String, String>{
|
||||
'FLUTTER_ROOT': Directory.current.path,
|
||||
},
|
||||
environment: pubEnvironment,
|
||||
);
|
||||
printStream(process.stdout, prefix: 'pub:stdout: ');
|
||||
printStream(process.stderr, prefix: 'pub:stderr: ');
|
||||
@@ -84,9 +95,10 @@ dependencies:
|
||||
|
||||
// Verify which version of dartdoc we're using.
|
||||
final ProcessResult result = Process.runSync(
|
||||
'../../bin/cache/dart-sdk/bin/pub',
|
||||
pubExecutable,
|
||||
<String>['global', 'run', 'dartdoc', '--version'],
|
||||
workingDirectory: 'dev/docs',
|
||||
environment: pubEnvironment,
|
||||
);
|
||||
print('\n${result.stdout}');
|
||||
|
||||
@@ -113,9 +125,10 @@ dependencies:
|
||||
}
|
||||
|
||||
process = await Process.start(
|
||||
'../../bin/cache/dart-sdk/bin/pub',
|
||||
pubExecutable,
|
||||
args,
|
||||
workingDirectory: 'dev/docs',
|
||||
environment: pubEnvironment,
|
||||
);
|
||||
printStream(process.stdout, prefix: 'dartdoc:stdout: ',
|
||||
filter: kVerbose ? const <Pattern>[] : <Pattern>[
|
||||
|
||||
Reference in New Issue
Block a user