Skip to content

Commit c05b6c5

Browse files
FatmeFatme
Fatme
authored and
Fatme
committed
Merge pull request #436 from NativeScript/logcat-printer
Logcat printer
2 parents 859cf66 + 644ad0b commit c05b6c5

File tree

9 files changed

+35
-13
lines changed

9 files changed

+35
-13
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ emulate android
33

44
Usage | Synopsis
55
---|---
6-
Run in the native emulator | `$ tns emulate android [--avd <Name>] [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
7-
Run in Genymotion | `$ tns emulate android --geny <GenyName> [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
8-
Run in the default Android virtual device or in a currently running emulator | `$ tns emulate android [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
6+
Run in the native emulator | `$ tns emulate android [--avd <Name>] [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
7+
Run in Genymotion | `$ tns emulate android --geny <GenyName> [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
8+
Run in the default Android virtual device or in a currently running emulator | `$ tns emulate android [--path <Directory>] [--timeout <Seconds>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
99

1010
Builds the specified project and runs it in the native emulator from the Android SDK or Genymotion. <% if(isHtml) { %>If you do not select an Android virtual device (AVD) with the `--avd` option or a Genymotion virtual device with the `--geny` option, your app runs in the default AVD or a currently running emulator, if any. <% } %>
1111

@@ -19,6 +19,7 @@ Builds the specified project and runs it in the native emulator from the Android
1919
* `--keyStorePassword` - Provides the password for the keystore file specified with --keyStorePath. You can use the `--keyStore*` options along with --release to produce a signed release build. You need to specify all `--keyStore*` options.
2020
* `--keyStoreAlias` - Provides the alias for the keystore file specified with `--keyStorePath`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
2121
* `--keyStoreAliasPassword` - Provides the password for the alias specified with `--keStoreAliasPassword`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
22+
* `--justlaunch` - If set, does not print application output on the console. Otherwise prints the application output on the console.
2223

2324
### Attributes
2425
* `<Name>` is the name of the Android virtual device that you want to use as listed by `$ android list avd`

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ run android
33

44
Usage | Synopsis
55
---|---
6-
Run on all connected devices and running emulators | `$ tns run android [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
7-
Run on a selected connected device or running emulator | `$ tns run android --device <Device ID> [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
8-
Start an emulator and run the app inside it | `$ tns run android --emulator [<Emulator Options>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release]`
6+
Run on all connected devices and running emulators | `$ tns run android [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
7+
Run on a selected connected device or running emulator | `$ tns run android --device <Device ID> [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
8+
Start an emulator and run the app inside it | `$ tns run android --emulator [<Emulator Options>] [--keyStorePath <File Path> --keyStorePassword <Password> --keyStoreAlias <Name> --keyStoreAliasPassword <Password>] [--release] [--justlaunch]`
99

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.
1111

@@ -17,6 +17,7 @@ Runs your project on a connected Android device or in a native Android emulator,
1717
* `--keyStorePassword` - Provides the password for the keystore file specified with `--keyStorePath`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
1818
* `--keyStoreAlias` - Provides the alias for the keystore file specified with `--keyStorePath`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
1919
* `--keyStoreAliasPassword` - Provides the password for the alias specified with `--keStoreAliasPassword`. You can use the `--keyStore*` options along with `--release` to produce a signed release build. You need to specify all `--keyStore*` options.
20+
* `--justlaunch` - If set, does not print application output on the console. Otherwise prints the application output on the console.
2021

2122
### Attributes
2223
* `<Device ID>` is the index or name of the target device as listed by `$ tns device android`

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ run ios
33

44
Usage | Synopsis
55
---|---
6-
Run on all connected devices | `$ tns run ios [--release]`
7-
Run on a selected connected device | `$ tns run ios [--device <Device ID>] [--release]`
6+
Run on all connected devices | `$ tns run ios [--release] [--justlaunch]`
7+
Run on a selected connected device | `$ tns run ios [--device <Device ID>] [--release] [--justlaunch]`
88
Start an emulator and run the app inside it | `$ tns run ios --emulator [<Emulator Options>] [--release]`
99

1010
Runs your project on a connected iOS device or in the iOS Simulator, if configured. This is shorthand for prepare, build, and deploy.
@@ -17,6 +17,7 @@ Runs your project on a connected iOS device or in the iOS Simulator, if configur
1717
* `--device` - Specifies a connected device on which to run the app.
1818
* `--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.
1919
* `--release` - If set, produces a release build. Otherwise, produces a debug build.
20+
* `--justlaunch` - If set, does not print application output on the console. Otherwise prints the application output on the console.
2021

2122
### Attributes
2223
* `<Device ID>` is the index or name of the target device as listed by `$ tns device ios`

lib/bootstrap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,5 @@ $injector.require("optionsService", "./services/options-service");
4949
$injector.require("dynamicHelpProvider", "./dynamic-help-provider");
5050
$injector.require("mobilePlatformsCapabilities", "./mobile-platforms-capabilities");
5151
$injector.require("commandsServiceProvider", "./providers/commands-service-provider");
52+
53+
$injector.require("logcatPrinter", "./providers/logcat-printer");

lib/providers/logcat-printer.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
///<reference path="../.d.ts"/>
2+
"use strict";
3+
4+
export class LogcatPrinter implements Mobile.ILogcatPrinter {
5+
constructor(private $logger: ILogger) { }
6+
7+
public print(line: string): void {
8+
this.$logger.out(line);
9+
}
10+
11+
}
12+
$injector.register("logcatPrinter", LogcatPrinter);

lib/services/platform-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export class PlatformService implements IPlatformService {
1818
private $platformsData: IPlatformsData,
1919
private $projectData: IProjectData,
2020
private $projectDataService: IProjectDataService,
21-
private $prompter: IPrompter) { }
21+
private $prompter: IPrompter,
22+
private $commandsService: ICommandsService) { }
2223

2324
public addPlatforms(platforms: string[]): IFuture<void> {
2425
return (() => {
@@ -190,7 +191,6 @@ export class PlatformService implements IPlatformService {
190191
return (() => {
191192
platform = platform.toLowerCase();
192193

193-
this.preparePlatform(platform).wait();
194194
if (options.emulator) {
195195
this.deployOnEmulator(platform).wait();
196196
} else {
@@ -242,7 +242,7 @@ export class PlatformService implements IPlatformService {
242242
this.$devicesServices.initialize({platform: platform, deviceId: options.device}).wait();
243243
var action = (device: Mobile.IDevice): IFuture<void> => { return device.deploy(packageFile, this.$projectData.projectId); };
244244
this.$devicesServices.execute(action).wait();
245-
245+
this.$commandsService.tryExecuteCommand("device", ["run", this.$projectData.projectId]).wait();
246246
}).future<void>()();
247247
}
248248

test/platform-commands.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ function createTestInjector() {
9999
testInjector.register("commandsServiceProvider", {
100100
registerDynamicSubCommands: () => {}
101101
});
102-
102+
testInjector.register("commandsService", {
103+
tryExecuteCommand: () => {}
104+
});
103105

104106
return testInjector;
105107
}

test/platform-service.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ function createTestInjector() {
3838
testInjector.register('projectDataService', stubs.ProjectDataService);
3939
testInjector.register('prompter', {});
4040
testInjector.register('lockfile', stubs.LockFile);
41+
testInjector.register("commandsService", {
42+
tryExecuteCommand: () => {}
43+
});
4144

4245
return testInjector;
4346
}

0 commit comments

Comments
 (0)