@@ -134,6 +134,13 @@ export class PlatformService implements IPlatformService {
134
134
}
135
135
this . $projectDataService . setValue ( platformData . frameworkPackageName , frameworkPackageNameData ) ;
136
136
137
+ if ( pathToTemplate ) {
138
+ let installedTemplateName = path . basename ( pathToTemplate ) ;
139
+ if ( coreModuleName !== installedTemplateName ) {
140
+ this . $npm . uninstall ( installedTemplateName , { save : true } ) . wait ( ) ;
141
+ }
142
+ }
143
+
137
144
return coreModuleName ;
138
145
139
146
} ) . future < string > ( ) ( ) ;
@@ -149,7 +156,6 @@ export class PlatformService implements IPlatformService {
149
156
}
150
157
151
158
if ( selectedTemplate ) {
152
- let tempDir = temp . mkdirSync ( "platform-template" ) ;
153
159
try {
154
160
/*
155
161
* Output of npm.install is array of arrays. For example:
@@ -160,8 +166,8 @@ export class PlatformService implements IPlatformService {
160
166
* '..\\..\\..\\android-platform-template' ] ]
161
167
* Project successfully created.
162
168
*/
163
- let pathToTemplate = this . $npm . install ( selectedTemplate , tempDir ) . wait ( ) [ 0 ] ;
164
- return { selectedTemplate, pathToTemplate } ;
169
+ let templateName = this . $npm . install ( selectedTemplate , this . $projectData . projectDir , { save : true } ) . wait ( ) [ 0 ] ;
170
+ return { selectedTemplate, pathToTemplate : path . join ( this . $projectData . projectDir , constants . NODE_MODULES_FOLDER_NAME , templateName ) } ;
165
171
} catch ( err ) {
166
172
this . $logger . trace ( "Error while trying to install specified template: " , err ) ;
167
173
this . $errors . failWithoutHelp ( `Unable to install platform template ${ selectedTemplate } . Make sure the specified value is valid.` ) ;
@@ -348,7 +354,7 @@ export class PlatformService implements IPlatformService {
348
354
}
349
355
let platformData = this . $platformsData . getPlatformData ( platform ) ;
350
356
let forDevice = ! buildConfig || buildConfig . buildForDevice ;
351
- let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
357
+ let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
352
358
if ( ! this . $fs . exists ( outputPath ) ) {
353
359
return true ;
354
360
}
@@ -484,7 +490,7 @@ export class PlatformService implements IPlatformService {
484
490
this . $devicesService . initialize ( { platform : platform , deviceId : this . $options . device } ) . wait ( ) ;
485
491
let found : Mobile . IDeviceInfo [ ] = [ ] ;
486
492
if ( this . $devicesService . hasDevices ) {
487
- found = this . $devicesService . getDevices ( ) . filter ( ( device :Mobile . IDeviceInfo ) => device . identifier === this . $options . device ) ;
493
+ found = this . $devicesService . getDevices ( ) . filter ( ( device : Mobile . IDeviceInfo ) => device . identifier === this . $options . device ) ;
488
494
}
489
495
if ( found . length === 0 ) {
490
496
this . $errors . fail ( "Cannot find device with name: %s" , this . $options . device ) ;
@@ -514,7 +520,7 @@ export class PlatformService implements IPlatformService {
514
520
let deviceFilePath = this . getDeviceBuildInfoFilePath ( device ) ;
515
521
try {
516
522
return JSON . parse ( this . readFile ( device , deviceFilePath ) . wait ( ) ) ;
517
- } catch ( e ) {
523
+ } catch ( e ) {
518
524
return null ;
519
525
} ;
520
526
} ) . future < IBuildInfo > ( ) ( ) ;
@@ -527,7 +533,7 @@ export class PlatformService implements IPlatformService {
527
533
try {
528
534
let buildInfoTime = this . $fs . readJson ( buildInfoFile ) ;
529
535
return buildInfoTime ;
530
- } catch ( e ) {
536
+ } catch ( e ) {
531
537
return null ;
532
538
}
533
539
}
0 commit comments