Skip to content

run command now can watch for changes #1895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/man_pages/project/testing/run-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Start an emulator and run the app inside it | `$ tns run android --emulator [<Em
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.

### Options
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device.
* `--device` - Specifies a connected device on which to run the app.
* `--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`.
* `--release` - If set, produces a release build. Otherwise, produces a debug build. When set, you must also specify the `--key-store-*` options.
Expand Down
1 change: 1 addition & 0 deletions docs/man_pages/project/testing/run-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
<% 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).<% } %>

### Options
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device.
* `--device` - Specifies a connected device on which to run the app.
* `--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.
* `--release` - If set, produces a release build. Otherwise, produces a debug build.
Expand Down
23 changes: 16 additions & 7 deletions lib/commands/run.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
export class RunCommandBase {
constructor(private $platformService: IPlatformService) { }
constructor(private $platformService: IPlatformService,
private $usbLiveSyncService: ILiveSyncService,
protected $options: IOptions) { }

public executeCore(args: string[], buildConfig?: IBuildConfig): IFuture<void> {
return this.$platformService.runPlatform(args[0], buildConfig);
if (this.$options.watch) {
return this.$usbLiveSyncService.liveSync(args[0]);
} else {
return this.$platformService.runPlatform(args[0], buildConfig);
}
}
}

export class RunIosCommand extends RunCommandBase implements ICommand {
constructor($platformService: IPlatformService,
private $platformsData: IPlatformsData) {
super($platformService);
private $platformsData: IPlatformsData,
$usbLiveSyncService: ILiveSyncService,
$options: IOptions) {
super($platformService, $usbLiveSyncService, $options);
}

public allowedParameters: ICommandParameter[] = [];
Expand All @@ -23,9 +31,10 @@ $injector.registerCommand("run|ios", RunIosCommand);
export class RunAndroidCommand extends RunCommandBase implements ICommand {
constructor($platformService: IPlatformService,
private $platformsData: IPlatformsData,
private $options: IOptions,
private $errors: IErrors) {
super($platformService);
$usbLiveSyncService: ILiveSyncService,
$options: IOptions,
private $errors: IErrors) {
super($platformService, $usbLiveSyncService, $options);
}

public allowedParameters: ICommandParameter[] = [];
Expand Down