Skip to content

Commit 5d9e675

Browse files
authored
Merge pull request #1895 from NativeScript/run-watch
run command now can watch for changes
2 parents c5c5c79 + 7823c3b commit 5d9e675

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

docs/man_pages/project/testing/run-android.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Start an emulator and run the app inside it | `$ tns run android --emulator [<Em
1010
Runs your project on a connected Android device or in a native Android emulator, if configured. This is shorthand for prepare, build and deploy. While your app is running, prints the output from the application in the console.
1111

1212
### Options
13+
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device.
1314
* `--device` - Specifies a connected device on which to run the app.
1415
* `--emulator` - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by `$ tns help emulate android`.
1516
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.

docs/man_pages/project/testing/run-ios.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
1414
<% if(isHtml) { %>> <% } %>IMPORTANT: Before building for iOS device, verify that you have configured a valid pair of certificate and provisioning profile on your OS X system. <% if(isHtml) { %>For more information, see [Obtaining Signing Identities and Downloading Provisioning Profiles](https://developer.apple.com/library/mac/recipes/xcode_help-accounts_preferences/articles/obtain_certificates_and_provisioning_profiles.html).<% } %>
1515

1616
### Options
17+
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device.
1718
* `--device` - Specifies a connected device on which to run the app.
1819
* `--emulator` - If set, runs the app in a native emulator for the target platform, if configured. When set, you can also set any other valid combination of emulator options as listed by `$ tns help emulate ios`. You cannot use `--device` and `--emulator` simultaneously.
1920
* `--release` - If set, produces a release build. Otherwise, produces a debug build.

lib/commands/run.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
export class RunCommandBase {
2-
constructor(private $platformService: IPlatformService) { }
2+
constructor(private $platformService: IPlatformService,
3+
private $usbLiveSyncService: ILiveSyncService,
4+
protected $options: IOptions) { }
35

46
public executeCore(args: string[], buildConfig?: IBuildConfig): IFuture<void> {
5-
return this.$platformService.runPlatform(args[0], buildConfig);
7+
if (this.$options.watch) {
8+
return this.$usbLiveSyncService.liveSync(args[0]);
9+
} else {
10+
return this.$platformService.runPlatform(args[0], buildConfig);
11+
}
612
}
713
}
814

915
export class RunIosCommand extends RunCommandBase implements ICommand {
1016
constructor($platformService: IPlatformService,
11-
private $platformsData: IPlatformsData) {
12-
super($platformService);
17+
private $platformsData: IPlatformsData,
18+
$usbLiveSyncService: ILiveSyncService,
19+
$options: IOptions) {
20+
super($platformService, $usbLiveSyncService, $options);
1321
}
1422

1523
public allowedParameters: ICommandParameter[] = [];
@@ -23,9 +31,10 @@ $injector.registerCommand("run|ios", RunIosCommand);
2331
export class RunAndroidCommand extends RunCommandBase implements ICommand {
2432
constructor($platformService: IPlatformService,
2533
private $platformsData: IPlatformsData,
26-
private $options: IOptions,
27-
private $errors: IErrors) {
28-
super($platformService);
34+
$usbLiveSyncService: ILiveSyncService,
35+
$options: IOptions,
36+
private $errors: IErrors) {
37+
super($platformService, $usbLiveSyncService, $options);
2938
}
3039

3140
public allowedParameters: ICommandParameter[] = [];

0 commit comments

Comments
 (0)