Add '-t' option to 'attach' command. (#20539)
* Add '-t' option to 'attach' command. * Add test * Make analyzer happy * Fix tests so they use memory file system and can find lib/main.dart
This commit is contained in:
committed by
GitHub
parent
b5b55447a4
commit
e1534b8ecb
@@ -35,7 +35,7 @@ final String ipv4Loopback = InternetAddress.loopbackIPv4.address;
|
||||
/// As soon as a new observatory is detected the command attaches to it and
|
||||
/// enables hot reloading.
|
||||
class AttachCommand extends FlutterCommand {
|
||||
AttachCommand({bool verboseHelp = false}) {
|
||||
AttachCommand({bool verboseHelp = false, this.hotRunnerFactory}) {
|
||||
addBuildModeFlags(defaultToRelease: false);
|
||||
argParser
|
||||
..addOption(
|
||||
@@ -53,8 +53,12 @@ class AttachCommand extends FlutterCommand {
|
||||
help: 'Handle machine structured JSON command input and provide output\n'
|
||||
'and progress in machine friendly format.',
|
||||
);
|
||||
usesTargetOption();
|
||||
hotRunnerFactory ??= new HotRunnerFactory();
|
||||
}
|
||||
|
||||
HotRunnerFactory hotRunnerFactory;
|
||||
|
||||
@override
|
||||
final String name = 'attach';
|
||||
|
||||
@@ -116,8 +120,9 @@ class AttachCommand extends FlutterCommand {
|
||||
final FlutterDevice flutterDevice = new FlutterDevice(device,
|
||||
trackWidgetCreation: false, previewDart2: argResults['preview-dart-2']);
|
||||
flutterDevice.observatoryUris = <Uri>[ observatoryUri ];
|
||||
final HotRunner hotRunner = new HotRunner(
|
||||
final HotRunner hotRunner = hotRunnerFactory.build(
|
||||
<FlutterDevice>[flutterDevice],
|
||||
target: targetFile,
|
||||
debuggingOptions: new DebuggingOptions.enabled(getBuildInfo()),
|
||||
packagesFilePath: globalResults['packages'],
|
||||
usesTerminalUI: daemon == null,
|
||||
@@ -145,3 +150,32 @@ class AttachCommand extends FlutterCommand {
|
||||
|
||||
Future<void> _validateArguments() async {}
|
||||
}
|
||||
|
||||
class HotRunnerFactory {
|
||||
HotRunner build(List<FlutterDevice> devices, {
|
||||
String target,
|
||||
DebuggingOptions debuggingOptions,
|
||||
bool usesTerminalUI = true,
|
||||
bool benchmarkMode = false,
|
||||
File applicationBinary,
|
||||
bool hostIsIde = false,
|
||||
String projectRootPath,
|
||||
String packagesFilePath,
|
||||
String dillOutputPath,
|
||||
bool stayResident = true,
|
||||
bool ipv6 = false,
|
||||
}) => new HotRunner(
|
||||
devices,
|
||||
target: target,
|
||||
debuggingOptions: debuggingOptions,
|
||||
usesTerminalUI: usesTerminalUI,
|
||||
benchmarkMode: benchmarkMode,
|
||||
applicationBinary: applicationBinary,
|
||||
hostIsIde: hostIsIde,
|
||||
projectRootPath: projectRootPath,
|
||||
packagesFilePath: packagesFilePath,
|
||||
dillOutputPath: dillOutputPath,
|
||||
stayResident: stayResident,
|
||||
ipv6: ipv6,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user