@@ -15,13 +15,13 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
1515 public async install ( ipaPath : string , deviceIdentifiers : string [ ] , errorHandler : DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
1616 this . assertIsInitialized ( ) ;
1717 this . $logger . trace ( `Installing ${ ipaPath } on devices with identifiers: ${ deviceIdentifiers } .` ) ;
18- return await this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . install ( ipaPath , deviceIdentifiers ) , deviceIdentifiers , errorHandler ) ;
18+ return await this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . install ( ipaPath , deviceIdentifiers ) , errorHandler ) ;
1919 }
2020
2121 public async uninstall ( appIdentifier : string , deviceIdentifiers : string [ ] , errorHandler : DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
2222 this . assertIsInitialized ( ) ;
2323 this . $logger . trace ( `Uninstalling ${ appIdentifier } from devices with identifiers: ${ deviceIdentifiers } .` ) ;
24- return await this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . uninstall ( appIdentifier , deviceIdentifiers ) , deviceIdentifiers , errorHandler ) ;
24+ return await this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . uninstall ( appIdentifier , deviceIdentifiers ) , errorHandler ) ;
2525 }
2626
2727 @cache ( )
@@ -38,7 +38,6 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
3838 }
3939 }
4040
41- @cache ( )
4241 public startDeviceLog ( deviceIdentifier : string , printLogFunction : ( data : string ) => void ) : void {
4342 this . assertIsInitialized ( ) ;
4443 this . setShouldDispose ( false ) ;
@@ -55,7 +54,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
5554 public async apps ( deviceIdentifiers : string [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceAppInfo > {
5655 this . assertIsInitialized ( ) ;
5756 this . $logger . trace ( `Getting applications information for devices with identifiers: ${ deviceIdentifiers } ` ) ;
58- return this . getMultipleResults ( ( ) => this . deviceLib . apps ( deviceIdentifiers ) , deviceIdentifiers , errorHandler ) ;
57+ return this . getMultipleResults ( ( ) => this . deviceLib . apps ( deviceIdentifiers ) , errorHandler ) ;
5958 }
6059
6160 public async listDirectory ( listArray : IOSDeviceLib . IReadOperationData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceMultipleResponse > {
@@ -65,7 +64,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
6564 this . $logger . trace ( `Listing directory: ${ l . path } for application ${ l . appId } on device with identifier: ${ l . deviceId } .` ) ;
6665 } ) ;
6766
68- return this . getMultipleResults < IOSDeviceLib . IDeviceMultipleResponse > ( ( ) => this . deviceLib . list ( listArray ) , this . getDeviceIdentifiersArray ( listArray ) , errorHandler ) ;
67+ return this . getMultipleResults < IOSDeviceLib . IDeviceMultipleResponse > ( ( ) => this . deviceLib . list ( listArray ) , errorHandler ) ;
6968 }
7069
7170 public async readFiles ( deviceFilePaths : IOSDeviceLib . IReadOperationData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
@@ -75,7 +74,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
7574 this . $logger . trace ( `Reading file: ${ p . path } from application ${ p . appId } on device with identifier: ${ p . deviceId } .` ) ;
7675 } ) ;
7776
78- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . read ( deviceFilePaths ) , this . getDeviceIdentifiersArray ( deviceFilePaths ) , errorHandler ) ;
77+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . read ( deviceFilePaths ) , errorHandler ) ;
7978 }
8079
8180 public async downloadFiles ( deviceFilePaths : IOSDeviceLib . IFileOperationData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
@@ -85,10 +84,10 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
8584 this . $logger . trace ( `Downloading file: ${ d . source } from application ${ d . appId } on device with identifier: ${ d . deviceId } to ${ d . destination } .` ) ;
8685 } ) ;
8786
88- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . download ( deviceFilePaths ) , this . getDeviceIdentifiersArray ( deviceFilePaths ) , errorHandler ) ;
87+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . download ( deviceFilePaths ) , errorHandler ) ;
8988 }
9089
91- public uploadFiles ( files : IOSDeviceLib . IUploadFilesData [ ] ) : Promise < IOSDeviceLib . IDeviceResponse > [ ] {
90+ public uploadFiles ( files : IOSDeviceLib . IUploadFilesData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
9291 this . assertIsInitialized ( ) ;
9392
9493 _ . each ( files , f => {
@@ -97,7 +96,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
9796 this . $logger . trace ( `For application ${ f . appId } on device with identifier: ${ f . deviceId } .` ) ;
9897 } ) ;
9998
100- return this . deviceLib . upload ( files ) ;
99+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . upload ( files ) , errorHandler ) ;
101100 }
102101
103102 public async deleteFiles ( deleteArray : IOSDeviceLib . IDeleteFileData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
@@ -107,7 +106,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
107106 this . $logger . trace ( `Deleting file: ${ d . destination } from application ${ d . appId } on device with identifier: ${ d . deviceId } .` ) ;
108107 } ) ;
109108
110- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . delete ( deleteArray ) , this . getDeviceIdentifiersArray ( deleteArray ) , errorHandler ) ;
109+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . delete ( deleteArray ) , errorHandler ) ;
111110 }
112111
113112 public async start ( startArray : IOSDeviceLib . IDdiApplicationData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
@@ -117,7 +116,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
117116 this . $logger . trace ( `Starting application ${ s . appId } on device with identifier: ${ s . deviceId } .` ) ;
118117 } ) ;
119118
120- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . start ( startArray ) , this . getDeviceIdentifiersArray ( startArray ) , errorHandler ) ;
119+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . start ( startArray ) , errorHandler ) ;
121120 }
122121
123122 public async stop ( stopArray : IOSDeviceLib . IDdiApplicationData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
@@ -127,7 +126,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
127126 this . $logger . trace ( `Stopping application ${ s . appId } on device with identifier: ${ s . deviceId } .` ) ;
128127 } ) ;
129128
130- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . start ( stopArray ) , this . getDeviceIdentifiersArray ( stopArray ) , errorHandler ) ;
129+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . start ( stopArray ) , errorHandler ) ;
131130 }
132131
133132 public dispose ( signal ?: string ) : void {
@@ -147,7 +146,7 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
147146 this . $logger . trace ( `Sending notification ${ n . notificationName } to device with identifier: ${ n . deviceId } ` ) ;
148147 } ) ;
149148
150- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . notify ( notifyArray ) , this . getDeviceIdentifiersArray ( notifyArray ) , errorHandler ) ;
149+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . notify ( notifyArray ) , errorHandler ) ;
151150 }
152151
153152 public async connectToPort ( connectToPortArray : IOSDeviceLib . IConnectToPortData [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IOSDeviceResponse > {
@@ -157,26 +156,24 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
157156 this . $logger . trace ( `Connecting to port ${ c . port } on device with identifier: ${ c . deviceId } ` ) ;
158157 } ) ;
159158
160- return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . connectToPort ( connectToPortArray ) , this . getDeviceIdentifiersArray ( connectToPortArray ) , errorHandler ) ;
159+ return this . getMultipleResults < IOSDeviceLib . IDeviceResponse > ( ( ) => this . deviceLib . connectToPort ( connectToPortArray ) , errorHandler ) ;
161160 }
162161
163162 public setShouldDispose ( shouldDispose : boolean ) : void {
164163 this . shouldDispose = shouldDispose ;
165164 }
166165
167- private async getMultipleResults < T > ( getPromisesMethod : ( ) => Promise < T > [ ] , deviceIdentifiers : string [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IDictionary < T [ ] > > {
166+ private async getMultipleResults < T > ( getPromisesMethod : ( ) => Promise < T > [ ] , errorHandler ?: DeviceOperationErrorHandler ) : Promise < IDictionary < T [ ] > > {
168167 const result : T [ ] = [ ] ;
169168 const promises = getPromisesMethod ( ) ;
170169
171- for ( let i = 0 ; i < promises . length ; i ++ ) {
172- const promise = promises [ i ] ;
173-
170+ for ( let promise of promises ) {
174171 if ( errorHandler ) {
175172 try {
176173 result . push ( await promise ) ;
177174 } catch ( err ) {
178175 this . $logger . trace ( `Error while executing ios device operation: ${ err . message } with code: ${ err . code } ` ) ;
179- errorHandler ( { error : err , deviceIdentifier : deviceIdentifiers [ i ] } ) ;
176+ errorHandler ( err ) ;
180177 }
181178 } else {
182179 result . push ( await promise ) ;
@@ -186,10 +183,6 @@ export class IOSDeviceOperations implements IIOSDeviceOperations, IDisposable {
186183 return _ . groupBy ( result , r => ( < any > r ) . deviceId ) ;
187184 }
188185
189- private getDeviceIdentifiersArray ( deviceInformation : IOSDeviceLib . IDeviceId [ ] ) : string [ ] {
190- return _ . map ( deviceInformation , d => d . deviceId ) ;
191- }
192-
193186 private assertIsInitialized ( ) : void {
194187 assert . ok ( this . isInitialized , "iOS device operations not initialized." ) ;
195188 }
0 commit comments