Run pub get if flutter_tools.stamp changes (#3206)

This will help folks run pub get after they upgrade their flutter.git
revision.
This commit is contained in:
Adam Barth 2016-04-08 07:19:25 -07:00
parent 99e916d0e2
commit dd5831cb36

View File

@ -9,8 +9,21 @@ import 'package:path/path.dart' as path;
import '../base/logger.dart';
import '../base/process.dart';
import '../cache.dart';
import '../globals.dart';
bool _shouldRunPubGet({ File pubSpecYaml, File dotPackages }) {
if (!dotPackages.existsSync())
return true;
DateTime dotPackagesLastModified = dotPackages.lastModifiedSync();
if (pubSpecYaml.lastModifiedSync().isAfter(dotPackagesLastModified))
return true;
File flutterToolsStamp = new File(path.join(Cache.instance.getRoot().path, 'flutter_tools.stamp'));
if (flutterToolsStamp.lastModifiedSync().isAfter(dotPackagesLastModified))
return true;
return false;
}
Future<int> pubGet({
String directory,
bool skipIfAbsent: false,
@ -30,7 +43,7 @@ Future<int> pubGet({
return 1;
}
if (!checkLastModified || !dotPackages.existsSync() || pubSpecYaml.lastModifiedSync().isAfter(dotPackages.lastModifiedSync())) {
if (!checkLastModified || _shouldRunPubGet(pubSpecYaml: pubSpecYaml, dotPackages: dotPackages)) {
String command = upgrade ? 'upgrade' : 'get';
Status status = logger.startProgress("Running 'pub $command' in ${path.basename(directory)}...");
int code = await runCommandAndStreamOutput(