Commit fd50ccdd authored by John McCutchan's avatar John McCutchan Committed by GitHub

Enable hot mode by default. --no-hot disables it (#5794)

parent e85f1629
...@@ -65,8 +65,8 @@ class RunCommand extends RunCommandBase { ...@@ -65,8 +65,8 @@ class RunCommand extends RunCommandBase {
// Option to enable hot reloading. // Option to enable hot reloading.
argParser.addFlag('hot', argParser.addFlag('hot',
negatable: false, negatable: true,
defaultsTo: false, defaultsTo: true,
help: 'Run with support for hot reloading.'); help: 'Run with support for hot reloading.');
// Option to write the pid to a file. // Option to write the pid to a file.
...@@ -90,7 +90,7 @@ class RunCommand extends RunCommandBase { ...@@ -90,7 +90,7 @@ class RunCommand extends RunCommandBase {
String get usagePath { String get usagePath {
Device device = deviceForCommand; Device device = deviceForCommand;
String command = argResults['hot'] ? 'hotrun' : name; String command = shouldUseHotMode() ? 'hotrun' : name;
if (device == null) if (device == null)
return command; return command;
...@@ -111,6 +111,10 @@ class RunCommand extends RunCommandBase { ...@@ -111,6 +111,10 @@ class RunCommand extends RunCommandBase {
} }
} }
bool shouldUseHotMode() {
return argResults['hot'] && (getBuildMode() == BuildMode.debug);
}
@override @override
Future<int> runInProject() async { Future<int> runInProject() async {
int debugPort; int debugPort;
...@@ -143,16 +147,14 @@ class RunCommand extends RunCommandBase { ...@@ -143,16 +147,14 @@ class RunCommand extends RunCommandBase {
Cache.releaseLockEarly(); Cache.releaseLockEarly();
// Do some early error checks for hot mode. // Enable hot mode by default if ``--no-hot` was not passed and we are in
bool hotMode = argResults['hot']; // debug mode.
final bool hotMode = shouldUseHotMode();
if (hotMode) { if (hotMode) {
if (getBuildMode() != BuildMode.debug) {
printError('Hot mode only works with debug builds.');
return 1;
}
if (!deviceForCommand.supportsHotMode) { if (!deviceForCommand.supportsHotMode) {
printError('Hot mode is not supported by this device.'); printError('Hot mode is not supported by this device. '
'Run with --no-hot.');
return 1; return 1;
} }
} }
...@@ -164,7 +166,7 @@ class RunCommand extends RunCommandBase { ...@@ -164,7 +166,7 @@ class RunCommand extends RunCommandBase {
} }
ResidentRunner runner; ResidentRunner runner;
if (argResults['hot']) { if (hotMode) {
runner = new HotRunner( runner = new HotRunner(
deviceForCommand, deviceForCommand,
target: targetFile, target: targetFile,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment