8000 Fix android custom platform template installation. · NativeScript/nativescript-cli@a24263e · GitHub
[go: up one dir, main page]

Skip to content

Commit a24263e

Browse files
committed
Fix android custom platform template installation.
1 parent 07d399f commit a24263e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/node-package-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ export class NodePackageManager implements INodePackageManager {
2323
config = config || {};
2424
config["ignore-scripts"] = true;
2525
}
26+
let packageJsonPath = path.join(pathToSave, "package.json");
2627

27-
let jsonContentBefore = this.$fs.readJson(path.join(pathToSave, "package.json"));
28+
let jsonContentBefore = this.$fs.readJson(packageJsonPath);
2829
let dependenciesBefore = _.keys(jsonContentBefore.dependencies).concat(_.keys(jsonContentBefore.devDependencies));
2930

3031
let flags = this.getFlagsString(config, true);

lib/services/platform-service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ export class PlatformService implements IPlatformService {
133133
frameworkPackageNameData.template = customTemplateOptions.selectedTemplate;
134134
}
135135
this.$projectDataService.setValue(platformData.frameworkPackageName, frameworkPackageNameData);
136+
let installedTemplateName = path.basename(pathToTemplate);
137+
if(coreModuleName !== installedTemplateName) {
138+
this.$npm.uninstall(installedTemplateName, { save: true }).wait();
139+
}
136140

137141
return coreModuleName;
138142

@@ -149,7 +153,6 @@ export class PlatformService implements IPlatformService {
149153
}
150154

151155
if (selectedTemplate) {
152-
let tempDir = temp.mkdirSync("platform-template");
153156
try {
154157
/*
155158
* Output of npm.install is array of arrays. For example:
@@ -160,8 +163,8 @@ export class PlatformService implements IPlatformService {
160163
* '..\\..\\..\\android-platform-template' ] ]
161164
* Project successfully created.
162165
*/
163-
let pathToTemplate = this.$npm.install(selectedTemplate, tempDir).wait()[0];
164-
return { selectedTemplate, pathToTemplate };
166+
let templateName = this.$npm.install(selectedTemplate, this.$projectData.projectDir, { save: true }).wait()[0];
167+
return { selectedTemplate, pathToTemplate: path.join(this.$projectData.projectDir, constants.NODE_MODULES_FOLDER_NAME, templateName)};
165168
} catch (err) {
166169
this.$logger.trace("Error while trying to install specified template: ", err);
167170
this.$errors.failWithoutHelp(`Unable to install platform template ${selectedTemplate}. Make sure the specified value is valid.`);

0 commit comments

Comments
 (0)
0