Skip to content

Commit 2e45034

Browse files
committed
fix: fix: install the latest compatible v2 templates in stead of the latest tag
1 parent 59f2ed3 commit 2e45034

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/services/project-templates-service.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
3030
}
3131

3232
const templateName = constants.RESERVED_TEMPLATE_NAMES[name.toLowerCase()] || name;
33-
version = version || await this.$npmInstallationManager.getLatestCompatibleVersion(templateName);
34-
const fullTemplateName = `${templateName}@${version}`;
33+
if (!this.$fs.exists(templateName)) {
34+
version = version || await this.$npmInstallationManager.getLatestCompatibleVersion(templateName);
35+
}
36+
37+
const fullTemplateName = version ? `${templateName}@${version}` : templateName;
3538
const templatePackageJsonContent = await this.getTemplatePackageJsonContent(fullTemplateName);
3639
const templateVersion = await this.getTemplateVersion(fullTemplateName);
3740

test/project-templates-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function createTestInjector(configuration: { shouldNpmInstallThrow?: boolean, pa
1515
injector.register("errors", stubs.ErrorsStub);
1616
injector.register("logger", stubs.LoggerStub);
1717
injector.register("fs", {
18-
exists: (pathToCheck: string) => true,
18+
exists: (pathToCheck: string) => false,
1919

2020
readJson: (pathToFile: string) => configuration.packageJsonContent || {},
2121

0 commit comments

Comments
 (0)