dev/update_packages.dart --upgrade

Add an --upgrade flag to the dev/update_packages.dart flag which runs
'pub upgrade' instead of 'pub get'. Tell people to use this when using
'flutter analyze' since 'pub get' doesn't have the same guarantee of
getting everything in sync.
This commit is contained in:
Ian Hickson
2015-11-27 20:01:13 -08:00
parent 33ca330797
commit 92a6212007
2 changed files with 19 additions and 9 deletions

View File

@@ -6,11 +6,15 @@
import 'dart:io';
final String binaryName = Platform.isWindows ? 'pub.bat' : 'pub';
update(Directory directory) {
void update(Directory directory, bool upgrade) {
for (FileSystemEntity dir in directory.listSync()) {
if (dir is Directory) {
print("Updating ${dir.path}...");
ProcessResult result = Process.runSync(binaryName, ['get'], workingDirectory: dir.path);
ProcessResult result = Process.runSync(
binaryName,
[ upgrade ? 'upgrade' : 'get' ],
workingDirectory: dir.path
);
if (result.exitCode != 0) {
print("... failed with exit code ${result.exitCode}.");
print(result.stdout);
@@ -20,8 +24,9 @@ update(Directory directory) {
}
}
main() {
void main(List<String> arguments) {
bool upgrade = arguments.length > 0 && arguments[0] == '--upgrade';
String FLUTTER_ROOT = new File(Platform.script.toFilePath()).parent.parent.path;
update(new Directory("$FLUTTER_ROOT/packages"));
update(new Directory("$FLUTTER_ROOT/examples"));
update(new Directory("$FLUTTER_ROOT/packages"), upgrade);
update(new Directory("$FLUTTER_ROOT/examples"), upgrade);
}