Skip to content

Commit 524ff68

Browse files
author
Fatme
authored
Merge pull request #3725 from NativeScript/fatme/fix-tracked-template-name
chore: fix the template name that will be send to google analytics
2 parents e106b94 + 44bb8ca commit 524ff68

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/services/project-templates-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
9292
private getTemplateNameToBeTracked(templateName: string, packageJsonContent: any): string {
9393
try {
9494
if (this.$fs.exists(templateName)) {
95-
const templateNameToBeTracked = this.$fs.exists(path.join(templateName, constants.PACKAGE_JSON_FILE_NAME)) ? packageJsonContent.name : path.basename(templateName);
95+
const templateNameToBeTracked = (packageJsonContent && packageJsonContent.name) || path.basename(templateName);
9696
return `${constants.ANALYTICS_LOCAL_TEMPLATE_PREFIX}${templateNameToBeTracked}`;
9797
}
9898

test/project-templates-service.ts

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ describe("project-templates-service", () => {
163163
const localTemplatePath = `/Users/username/${templateName}`;
164164
const fs = testInjector.resolve<IFileSystem>("fs");
165165
fs.exists = (localPath: string): boolean => path.basename(localPath) !== constants.PACKAGE_JSON_FILE_NAME;
166+
const pacoteService = testInjector.resolve<IPacoteService>("pacoteService");
167+
pacoteService.manifest = () => Promise.resolve({ });
166168
await projectTemplatesService.prepareTemplate(localTemplatePath, "tempFolder");
167169
assert.deepEqual(dataSentToGoogleAnalytics, [
168170
{

0 commit comments

Comments
 (0)