have flutter precache print if there's no work to do (#3213)
* have flutter precache print if there's no work to do * tweak precache
This commit is contained in:
parent
f8c1d619a6
commit
c00d61f6ec
@ -38,19 +38,29 @@ class Cache {
|
|||||||
return new Directory(path.join(getCacheArtifacts().path, name));
|
return new Directory(path.join(getCacheArtifacts().path, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
String getVersionFor(String kArtifactName) {
|
String getVersionFor(String artifactName) {
|
||||||
File versionFile = new File(path.join(getRoot().path, '$kArtifactName.version'));
|
File versionFile = new File(path.join(getRoot().path, '$artifactName.version'));
|
||||||
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
|
return versionFile.existsSync() ? versionFile.readAsStringSync().trim() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getStampFor(String kArtifactName) {
|
String getStampFor(String artifactName) {
|
||||||
File stampFile = new File(path.join(getRoot().path, '$kArtifactName.stamp'));
|
File stampFile = getStampFileFor(artifactName);
|
||||||
return stampFile.existsSync() ? stampFile.readAsStringSync().trim() : null;
|
return stampFile.existsSync() ? stampFile.readAsStringSync().trim() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStampFor(String kArtifactName, String version) {
|
void setStampFor(String artifactName, String version) {
|
||||||
File stampFile = new File(path.join(getRoot().path, '$kArtifactName.stamp'));
|
getStampFileFor(artifactName).writeAsStringSync(version);
|
||||||
stampFile.writeAsStringSync(version);
|
}
|
||||||
|
|
||||||
|
File getStampFileFor(String artifactName) {
|
||||||
|
return new File(path.join(getRoot().path, '$artifactName.stamp'));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isUpToDate() {
|
||||||
|
MaterialFonts materialFonts = new MaterialFonts(cache);
|
||||||
|
FlutterEngine engine = new FlutterEngine(cache);
|
||||||
|
|
||||||
|
return materialFonts.isUpToDate() && engine.isUpToDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getThirdPartyFile(String urlStr, String serviceName, {
|
Future<String> getThirdPartyFile(String urlStr, String serviceName, {
|
||||||
|
@ -6,7 +6,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
|
|
||||||
import '../cache.dart';
|
import '../globals.dart';
|
||||||
|
|
||||||
class PrecacheCommand extends Command {
|
class PrecacheCommand extends Command {
|
||||||
@override
|
@override
|
||||||
@ -17,7 +17,11 @@ class PrecacheCommand extends Command {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> run() async {
|
Future<int> run() async {
|
||||||
await Cache.instance.updateAll();
|
if (cache.isUpToDate())
|
||||||
|
printStatus('All up-to-date.');
|
||||||
|
else
|
||||||
|
await cache.updateAll();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ bool _shouldRunPubGet({ File pubSpecYaml, File dotPackages }) {
|
|||||||
DateTime dotPackagesLastModified = dotPackages.lastModifiedSync();
|
DateTime dotPackagesLastModified = dotPackages.lastModifiedSync();
|
||||||
if (pubSpecYaml.lastModifiedSync().isAfter(dotPackagesLastModified))
|
if (pubSpecYaml.lastModifiedSync().isAfter(dotPackagesLastModified))
|
||||||
return true;
|
return true;
|
||||||
File flutterToolsStamp = new File(path.join(Cache.instance.getRoot().path, 'flutter_tools.stamp'));
|
File flutterToolsStamp = Cache.instance.getStampFileFor('flutter_tools');
|
||||||
if (flutterToolsStamp.lastModifiedSync().isAfter(dotPackagesLastModified))
|
if (flutterToolsStamp.lastModifiedSync().isAfter(dotPackagesLastModified))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user