Skip to content

Commit 64080f7

Browse files
author
Dimitar Kerezov
committed
Pass emulator flag and fix process.platform messages
1 parent 714275c commit 64080f7

File tree

7 files changed

+37
-22
lines changed

7 files changed

+37
-22
lines changed

lib/commands/appstore-list.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ListiOSApps implements ICommand {
1717

1818
public async execute(args: string[]): Promise<void> {
1919
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
20-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.iOS, process.platform);
20+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
2121
}
2222

2323
let username = args[0],

lib/commands/appstore-upload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class PublishIOS implements ICommand {
100100

101101
public async canExecute(args: string[]): Promise<boolean> {
102102
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
103-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.iOS, process.platform);
103+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
104104
}
105105

106106
return true;

lib/commands/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class BuildCommandBase {
3434

3535
protected validatePlatform(platform: string): void {
3636
if (!this.$platformService.isPlatformSupportedForOS(platform, this.$projectData)) {
37-
this.$errors.fail(`Applications for platform ${platform} can not be built on this OS - ${process.platform}`);
37+
this.$errors.fail(`Applications for platform ${platform} can not be built on this OS`);
3838
}
3939
}
4040
}

lib/commands/clean-app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class CleanAppIosCommand extends CleanAppCommandBase implements ICommand
2626

2727
public async execute(args: string[]): Promise<void> {
2828
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
29-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.iOS, process.platform);
29+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
3030
}
3131
return super.execute([this.$platformsData.availablePlatforms.iOS]);
3232
}
@@ -48,7 +48,7 @@ export class CleanAppAndroidCommand extends CleanAppCommandBase implements IComm
4848

4949
public async execute(args: string[]): Promise<void> {
5050
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
51-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.iOS, process.platform);
51+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
5252
}
5353
return super.execute([this.$platformsData.availablePlatforms.Android]);
5454
}

lib/commands/debug.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ export abstract class DebugPlatformCommand implements ICommand {
3030

3131
this.$config.debugLivesync = true;
3232

33-
await this.$devicesService.initialize({ deviceId: this.$options.device, platform: this.platform, skipDeviceDetectionInterval: true, skipInferPlatform: true });
33+
await this.$devicesService.initialize({
34+
35+
});
3436
await this.$devicesService.detectCurrentlyAttachedDevices();
3537

3638
const devices = this.$devicesService.getDeviceInstances();
@@ -73,7 +75,13 @@ export abstract class DebugPlatformCommand implements ICommand {
7375
}
7476

7577
public async canExecute(args: string[]): Promise<boolean> {
76-
await this.$devicesService.initialize({ platform: this.debugService.platform, deviceId: this.$options.device });
78+
await this.$devicesService.initialize({
79+
platform: this.platform,
80+
deviceId: this.$options.device,
81+
emulator: this.$options.emulator,
82+
skipDeviceDetectionInterval: true,
83+
skipInferPlatform: true
84+
});
7785
// Start emulator if --emulator is selected or no devices found.
7886
if (this.$options.emulator || this.$devicesService.deviceCount === 0) {
7987
return true;
@@ -120,7 +128,7 @@ export class DebugIOSCommand extends DebugPlatformCommand {
120128

121129
public async canExecute(args: string[]): Promise<boolean> {
122130
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
123-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.iOS, process.platform);
131+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
124132
}
125133

126134
return await super.canExecute(args) && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, this.$platformsData.availablePlatforms.iOS);
@@ -155,7 +163,7 @@ export class DebugAndroidCommand extends DebugPlatformCommand {
155163

156164
public async canExecute(args: string[]): Promise<boolean> {
157165
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.Android, this.$projectData)) {
158-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.Android, process.platform);
166+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS`);
159167
}
160168

161169
return await super.canExecute(args) && await this.$platformService.validateOptions(this.$options.provision, this.$projectData, this.$platformsData.availablePlatforms.Android);

lib/commands/run.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class RunCommandBase implements ICommand {
4242
await this.$devicesService.initialize({
4343
deviceId: this.$options.device,
4444
platform: this.platform,
45+
emulator: this.$options.emulator,
4546
skipDeviceDetectionInterval: true,
4647
skipInferPlatform: !this.platform
4748
});
@@ -124,7 +125,7 @@ export class RunIosCommand extends RunCommandBase implements ICommand {
124125

125126
public async execute(args: string[]): Promise<void> {
126127
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.iOS, this.$projectData)) {
127-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.iOS, process.platform);
128+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.iOS} can not be built on this OS`);
128129
}
129130

130131
return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
@@ -165,7 +166,7 @@ export class RunAndroidCommand extends RunCommandBase implements ICommand {
165166
public async canExecute(args: string[]): Promise<boolean> {
166167
await super.canExecute(args);
167168
if (!this.$platformService.isPlatformSupportedForOS(this.$devicePlatformsConstants.Android, this.$projectData)) {
168-
this.$errors.fail("Applications for platform %s can not be built on this OS - %s", this.$devicePlatformsConstants.Android, process.platform);
169+
this.$errors.fail(`Applications for platform ${this.$devicePlatformsConstants.Android} can not be built on this OS`);
169170
}
170171

171172
if (this.$options.release && (!this.$options.keyStorePath || !this.$options.keyStorePassword || !this.$options.keyStoreAlias || !this.$options.keyStoreAliasPassword)) {

lib/services/test-execution-service.ts

+17-11
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ class TestExecutionService implements ITestExecutionService {
4141
try {
4242
let platformData = this.$platformsData.getPlatformData(platform.toLowerCase(), projectData);
4343
let projectDir = projectData.projectDir;
44-
await this.$devicesService.initialize({ platform: platform, deviceId: this.$options.device });
44+
await this.$devicesService.initialize({
45+
platform: platform,
46+
deviceId: this.$options.device,
47+
emulator: this.$options.emulator
48+
});
4549
await this.$devicesService.detectCurrentlyAttachedDevices();
4650
let projectFilesPath = path.join(platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
4751

@@ -59,6 +63,7 @@ class TestExecutionService implements ITestExecutionService {
5963
if (!await this.$platformService.preparePlatform(platform, appFilesUpdaterOptions, this.$options.platformTemplate, projectData, this.$options)) {
6064
this.$errors.failWithoutHelp("Verify that listed files are well-formed and try again the operation.");
6165
}
66+
6267
this.detourEntryPoint(projectFilesPath);
6368

6469
const deployOptions: IDeployPlatformOptions = {
@@ -78,7 +83,8 @@ class TestExecutionService implements ITestExecutionService {
7883

7984
const devices = this.$devicesService.getDeviceInstances();
8085
// Now let's take data for each device:
81-
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices.filter(d => !this.platform || d.deviceInfo.platform === this.platform)
86+
const platformLowerCase = this.platform && this.platform.toLowerCase();
87+
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices.filter(d => !platformLowerCase || d.deviceInfo.platform.toLowerCase() === platformLowerCase)
8288
.map(d => {
8389
const info: ILiveSyncDeviceInfo = {
8490
identifier: d.deviceInfo.identifier,
@@ -99,19 +105,16 @@ class TestExecutionService implements ITestExecutionService {
99105

100106
await this.$platformService.buildPlatform(d.deviceInfo.platform, buildConfig, projectData);
101107
const pathToBuildResult = await this.$platformService.lastOutputPath(d.deviceInfo.platform, buildConfig, projectData);
102-
console.log("3##### return path to buildResult = ", pathToBuildResult);
103108
return pathToBuildResult;
104109
}
105110
};
106111

107112
return info;
108113
});
109114

110-
// TODO: Fix this call
111115
const liveSyncInfo: ILiveSyncInfo = { projectDir: projectData.projectDir, skipWatcher: !this.$options.watch || this.$options.justlaunch, watchAllFiles: this.$options.syncAllFiles };
116+
112117
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
113-
// TODO: Fix
114-
// await this.$liveSyncService.liveSync(platform, projectData, null, this.$options);
115118

116119
if (this.$options.debugBrk) {
117120
this.$logger.info('Starting debugger...');
@@ -142,7 +145,11 @@ class TestExecutionService implements ITestExecutionService {
142145
await this.$pluginsService.ensureAllDependenciesAreInstalled(projectData);
143146

144147
let projectDir = projectData.projectDir;
145-
await this.$devicesService.initialize({ platform: platform, deviceId: this.$options.device });
148+
await this.$devicesService.initialize({
149+
platform: platform,
150+
deviceId: this.$options.device,
151+
emulator: this.$options.emulator
152+
});
146153

147154
let karmaConfig = this.getKarmaConfiguration(platform, projectData),
148155
karmaRunner = this.$childProcess.fork(path.join(__dirname, "karma-execution.js")),
@@ -187,13 +194,14 @@ class TestExecutionService implements ITestExecutionService {
187194
} else {
188195
const devices = this.$devicesService.getDeviceInstances();
189196
// Now let's take data for each device:
190-
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices.filter(d => !this.platform || d.deviceInfo.platform === this.platform)
197+
const platformLowerCase = this.platform && this.platform.toLowerCase();
198+
const deviceDescriptors: ILiveSyncDeviceInfo[] = devices.filter(d => !platformLowerCase || d.deviceInfo.platform.toLowerCase() === platformLowerCase)
191199
.map(d => {
192200
const info: ILiveSyncDeviceInfo = {
193201
identifier: d.deviceInfo.identifier,
194202
buildAction: async (): Promise<string> => {
195203
const buildConfig: IBuildConfig = {
196-
buildForDevice: !d.isEmulator, // this.$options.forDevice,
204+
buildForDevice: !d.isEmulator,
197205
projectDir: this.$options.path,
198206
clean: this.$options.clean,
199207
teamId: this.$options.teamId,
@@ -208,15 +216,13 @@ class TestExecutionService implements ITestExecutionService {
208216

209217
await this.$platformService.buildPlatform(d.deviceInfo.platform, buildConfig, projectData);
210218
const pathToBuildResult = await this.$platformService.lastOutputPath(d.deviceInfo.platform, buildConfig, projectData);
211-
console.log("3##### return path to buildResult = ", pathToBuildResult);
212219
return pathToBuildResult;
213220
}
214221
};
215222

216223
return info;
217224
});
218225

219-
// TODO: Fix this call
220226
const liveSyncInfo: ILiveSyncInfo = { projectDir: projectData.projectDir, skipWatcher: !this.$options.watch || this.$options.justlaunch, watchAllFiles: this.$options.syncAllFiles };
221227
await this.$liveSyncService.liveSync(deviceDescriptors, liveSyncInfo);
222228
}

0 commit comments

Comments
 (0)