@@ -134,6 +134,13 @@ export class PlatformService implements IPlatformService {
134134 }
135135 this . $projectDataService . setValue ( platformData . frameworkPackageName , frameworkPackageNameData ) ;
136136
137+ if ( pathToTemplate ) {
138+ let installedTemplateName = path . basename ( pathToTemplate ) ;
139+ if ( coreModuleName !== installedTemplateName ) {
140+ this . $npm . uninstall ( installedTemplateName , { save : true } ) . wait ( ) ;
141+ }
142+ }
143+
137144 return coreModuleName ;
138145
139146 } ) . future < string > ( ) ( ) ;
@@ -149,7 +156,6 @@ export class PlatformService implements IPlatformService {
149156 }
150157
151158 if ( selectedTemplate ) {
152- let tempDir = temp . mkdirSync ( "platform-template" ) ;
153159 try {
154160 /*
155161 * Output of npm.install is array of arrays. For example:
@@ -160,8 +166,8 @@ export class PlatformService implements IPlatformService {
160166 * '..\\..\\..\\android-platform-template' ] ]
161167 * Project successfully created.
162168 */
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 ) } ;
165171 } catch ( err ) {
166172 this . $logger . trace ( "Error while trying to install specified template: " , err ) ;
167173 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 {
348354 }
349355 let platformData = this . $platformsData . getPlatformData ( platform ) ;
350356 let forDevice = ! buildConfig || buildConfig . buildForDevice ;
351- let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
357+ let outputPath = forDevice ? platformData . deviceBuildOutputPath : platformData . emulatorBuildOutputPath ;
352358 if ( ! this . $fs . exists ( outputPath ) ) {
353359 return true ;
354360 }
@@ -484,7 +490,7 @@ export class PlatformService implements IPlatformService {
484490 this . $devicesService . initialize ( { platform : platform , deviceId : this . $options . device } ) . wait ( ) ;
485491 let found : Mobile . IDeviceInfo [ ] = [ ] ;
486492 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 ) ;
488494 }
489495 if ( found . length === 0 ) {
490496 this . $errors . fail ( "Cannot find device with name: %s" , this . $options . device ) ;
@@ -514,7 +520,7 @@ export class PlatformService implements IPlatformService {
514520 let deviceFilePath = this . getDeviceBuildInfoFilePath ( device ) ;
515521 try {
516522 return JSON . parse ( this . readFile ( device , deviceFilePath ) . wait ( ) ) ;
517- } catch ( e ) {
523+ } catch ( e ) {
518524 return null ;
519525 } ;
520526 } ) . future < IBuildInfo > ( ) ( ) ;
@@ -527,7 +533,7 @@ export class PlatformService implements IPlatformService {
527533 try {
528534 let buildInfoTime = this . $fs . readJson ( buildInfoFile ) ;
529535 return buildInfoTime ;
530- } catch ( e ) {
536+ } catch ( e ) {
531537 return null ;
532538 }
533539 }
0 commit comments