Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit 252c027

Browse files
committed
refactoring after review
1 parent 2824966 commit 252c027

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

mobile/mobile-core/devices-service.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -384,26 +384,28 @@ If you are trying to run on specific emulator, use tns run –device <DeviceID>.
384384
await this.detectCurrentlyAttachedDevices();
385385
let deviceInstances = this.getDeviceInstances();
386386

387-
//if no --device is passed and no devices are found, the default emulator is started
388-
if (data && data.platform && !data.deviceId && _.isEmpty(deviceInstances)) {
389-
return await this.startEmulator(data.platform);
390-
}
387+
if(data && data.platform) {
388+
//if no --device is passed and no devices are found, the default emulator is started
389+
if (!data.deviceId && _.isEmpty(deviceInstances)) {
390+
return await this.startEmulator(data.platform);
391+
}
391392

392-
//check if --device(value) is running, if it's not or it's not the same as is specified, start with name from --device(value)
393-
if (data && data.platform && data.deviceId) {
394-
if (!helpers.isNumber(data.deviceId)) {
395-
let activeDeviceInstance = _.find(this.getDeviceInstances(), (device: Mobile.IDevice) => { return device.deviceInfo.identifier === data.deviceId; });
396-
if (!activeDeviceInstance) {
397-
return await this.startEmulator(data.platform, data.deviceId);
393+
//check if --device(value) is running, if it's not or it's not the same as is specified, start with name from --device(value)
394+
if (data.deviceId) {
395+
if (!helpers.isNumber(data.deviceId)) {
396+
let activeDeviceInstance = _.find(this.getDeviceInstances(), (device: Mobile.IDevice) => { return device.deviceInfo.identifier === data.deviceId; });
397+
if (!activeDeviceInstance) {
398+
return await this.startEmulator(data.platform, data.deviceId);
399+
}
398400
}
399401
}
400-
}
401402

402-
// if only emulator flag is passed and no other emulators are running, start default emulator
403-
if (data && data.platform && data.emulator && deviceInstances.length) {
404-
let runningDeviceInstance = _.some(deviceInstances, (value) => {return value.isEmulator; });
405-
if (!runningDeviceInstance) {
406-
return await this.startEmulator(data.platform);
403+
// if only emulator flag is passed and no other emulators are running, start default emulator
404+
if (data.emulator && deviceInstances.length) {
405+
let runningDeviceInstance = _.some(deviceInstances, (value) => {return value.isEmulator; });
406+
if (!runningDeviceInstance) {
407+
return await this.startEmulator(data.platform);
408+
}
407409
}
408410
}
409411
}

0 commit comments

Comments
 (0)