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:
@@ -9,8 +9,21 @@ import 'package:path/path.dart' as path;
|
|||||||
|
|
||||||
import '../base/logger.dart';
|
import '../base/logger.dart';
|
||||||
import '../base/process.dart';
|
import '../base/process.dart';
|
||||||
|
import '../cache.dart';
|
||||||
import '../globals.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({
|
Future<int> pubGet({
|
||||||
String directory,
|
String directory,
|
||||||
bool skipIfAbsent: false,
|
bool skipIfAbsent: false,
|
||||||
@@ -30,7 +43,7 @@ Future<int> pubGet({
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkLastModified || !dotPackages.existsSync() || pubSpecYaml.lastModifiedSync().isAfter(dotPackages.lastModifiedSync())) {
|
if (!checkLastModified || _shouldRunPubGet(pubSpecYaml: pubSpecYaml, dotPackages: dotPackages)) {
|
||||||
String command = upgrade ? 'upgrade' : 'get';
|
String command = upgrade ? 'upgrade' : 'get';
|
||||||
Status status = logger.startProgress("Running 'pub $command' in ${path.basename(directory)}...");
|
Status status = logger.startProgress("Running 'pub $command' in ${path.basename(directory)}...");
|
||||||
int code = await runCommandAndStreamOutput(
|
int code = await runCommandAndStreamOutput(
|
||||||
|
|||||||
Reference in New Issue
Block a user