diff --git a/definitions/mobile.d.ts b/definitions/mobile.d.ts index ab75789e..70ed7162 100644 --- a/definitions/mobile.d.ts +++ b/definitions/mobile.d.ts @@ -340,6 +340,7 @@ declare module Mobile { getDevicesForPlatform(platform: string): Mobile.IDevice[]; getDeviceInstances(): Mobile.IDevice[]; getDeviceByDeviceOption(): Mobile.IDevice; + getDeviceByName(name: string): Mobile.IDevice; isAndroidDevice(device: Mobile.IDevice): boolean; isiOSDevice(device: Mobile.IDevice): boolean; isiOSSimulator(device: Mobile.IDevice): boolean; diff --git a/mobile/mobile-core/devices-service.ts b/mobile/mobile-core/devices-service.ts index e5a651aa..487663ca 100644 --- a/mobile/mobile-core/devices-service.ts +++ b/mobile/mobile-core/devices-service.ts @@ -213,6 +213,10 @@ export class DevicesService implements Mobile.IDevicesService { return searchedDevice; } + public getDeviceByName(name: string): Mobile.IDevice { + return _.find(this.getDeviceInstances(), (device: Mobile.IDevice) => { return device.deviceInfo.displayName === name; }); + } + private startLookingForDevices(): IFuture { return (() => { this.$logger.trace("startLookingForDevices; platform is %s", this._platform); @@ -244,6 +248,8 @@ export class DevicesService implements Mobile.IDevicesService { device = this.getDeviceByIdentifier(deviceOption); } else if (helpers.isNumber(deviceOption)) { device = this.getDeviceByIndex(parseInt(deviceOption, 10)); + } else { + device = this.getDeviceByName(deviceOption); } if (!device) {