mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
add --force flag to precache (#31278)
This commit is contained in:
parent
b275e11170
commit
f5672b9316
@ -13,6 +13,8 @@ class PrecacheCommand extends FlutterCommand {
|
|||||||
PrecacheCommand() {
|
PrecacheCommand() {
|
||||||
argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
|
argParser.addFlag('all-platforms', abbr: 'a', negatable: false,
|
||||||
help: 'Precache artifacts for all platforms.');
|
help: 'Precache artifacts for all platforms.');
|
||||||
|
argParser.addFlag('force', abbr: 'f', negatable: false,
|
||||||
|
help: 'Force downloading of artifacts.');
|
||||||
argParser.addFlag('android', negatable: true, defaultsTo: true,
|
argParser.addFlag('android', negatable: true, defaultsTo: true,
|
||||||
help: 'Precache artifacts for Android development');
|
help: 'Precache artifacts for Android development');
|
||||||
argParser.addFlag('ios', negatable: true, defaultsTo: true,
|
argParser.addFlag('ios', negatable: true, defaultsTo: true,
|
||||||
@ -55,10 +57,11 @@ class PrecacheCommand extends FlutterCommand {
|
|||||||
requiredArtifacts.add(artifact);
|
requiredArtifacts.add(artifact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cache.isUpToDate()) {
|
final bool forceUpdate = argResults['force'];
|
||||||
printStatus('Already up-to-date.');
|
if (forceUpdate || !cache.isUpToDate()) {
|
||||||
} else {
|
|
||||||
await cache.updateAll(requiredArtifacts);
|
await cache.updateAll(requiredArtifacts);
|
||||||
|
} else {
|
||||||
|
printStatus('Already up-to-date.');
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,23 @@ void main() {
|
|||||||
Cache: () => cache,
|
Cache: () => cache,
|
||||||
FlutterVersion: () => flutterVersion,
|
FlutterVersion: () => flutterVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('Downloads artifacts when --force is provided', () async {
|
||||||
|
when(cache.isUpToDate()).thenReturn(true);
|
||||||
|
// Release lock between test cases.
|
||||||
|
Cache.releaseLockEarly();
|
||||||
|
final PrecacheCommand command = PrecacheCommand();
|
||||||
|
applyMocksToCommand(command);
|
||||||
|
await createTestCommandRunner(command).run(const <String>['precache', '--force']);
|
||||||
|
expect(artifacts, unorderedEquals(<DevelopmentArtifact>{
|
||||||
|
DevelopmentArtifact.universal,
|
||||||
|
DevelopmentArtifact.iOS,
|
||||||
|
DevelopmentArtifact.android,
|
||||||
|
}));
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
Cache: () => cache,
|
||||||
|
FlutterVersion: () => flutterVersion,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user