Adding a setup function for hot restart (#18921)
* Adding a setup function for hot restart that can be overwritten to perform any necessary initialization before a restart is started. * Adding a test for setupHotRestart * Removing local pubspec change * Fixing some type annotation errors * Responding to comments
This commit is contained in:
committed by
Alexander Aprelev
parent
d5d129803a
commit
e5d9feb59d
@@ -27,6 +27,11 @@ class HotRunnerConfig {
|
||||
bool computeDartDependencies = true;
|
||||
/// Should the hot runner assume that the minimal Dart dependencies do not change?
|
||||
bool stableDartDependencies = false;
|
||||
/// A hook for implementations to perform any necessary initialization prior
|
||||
/// to a hot restart. Should return true if the hot restart should continue.
|
||||
Future<bool> setupHotRestart() async {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
HotRunnerConfig get hotRunnerConfig => context[HotRunnerConfig];
|
||||
@@ -477,6 +482,10 @@ class HotRunner extends ResidentRunner {
|
||||
);
|
||||
try {
|
||||
final Stopwatch timer = new Stopwatch()..start();
|
||||
if (!(await hotRunnerConfig.setupHotRestart())) {
|
||||
status.cancel();
|
||||
return new OperationResult(1, 'setupHotRestart failed');
|
||||
}
|
||||
await _restartFromSources();
|
||||
timer.stop();
|
||||
status.cancel();
|
||||
|
||||
Reference in New Issue
Block a user