@@ -2,7 +2,7 @@ export class PutFileCommand implements ICommand {
22 constructor ( private $devicesService : Mobile . IDevicesService ,
33 private $stringParameter : ICommandParameter ,
44 private $options : IOptions ,
5- private $project : Project . IProjectBase ,
5+ private $projectData : IProjectData ,
66 private $errors : IErrors ) { }
77
88 allowedParameters : ICommandParameter [ ] = [ this . $stringParameter , this . $stringParameter , this . $stringParameter ] ;
@@ -11,12 +11,21 @@ export class PutFileCommand implements ICommand {
1111 await this . $devicesService . initialize ( { deviceId : this . $options . device , skipInferPlatform : true } ) ;
1212 let appIdentifier = args [ 2 ] ;
1313
14- if ( ! appIdentifier && ! this . $project . projectData ) {
15- this . $errors . failWithoutHelp ( "Please enter application identifier or execute this command in project." ) ;
14+ if ( ! appIdentifier ) {
15+ try {
16+ this . $projectData . initializeProjectData ( ) ;
17+ } catch ( err ) {
18+ // ignore the error
19+ }
20+ if ( ! this . $projectData . projectIdentifiers ) {
21+ this . $errors . failWithoutHelp ( "Please enter application identifier or execute this command in project." ) ;
22+ }
1623 }
1724
18- appIdentifier = appIdentifier || this . $project . projectData . AppIdentifier ;
19- const action = ( device : Mobile . IDevice ) => device . fileSystem . putFile ( args [ 0 ] , args [ 1 ] , appIdentifier ) ;
25+ const action = async ( device : Mobile . IDevice ) => {
26+ appIdentifier = appIdentifier || this . $projectData . projectIdentifiers [ device . deviceInfo . platform . toLowerCase ( ) ] ;
27+ await device . fileSystem . putFile ( args [ 0 ] , args [ 1 ] , appIdentifier ) ;
28+ } ;
2029 await this . $devicesService . execute ( action ) ;
2130 }
2231}
0 commit comments