Skip to content

Commit b2afcf7

Browse files
committed
fix: fix linting errors
1 parent 77dd128 commit b2afcf7

5 files changed

+80
-81
lines changed

lib/node-package-manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export class NodePackageManager implements INodePackageManager {
145145
return {
146146
name: templateName || fullPackageName,
147147
version: version
148-
}
148+
};
149149
}
150150

151151
public getPackageFullName(packageNameParts: INpmPackageNameParts): string {

lib/services/project-templates-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class ProjectTemplatesService implements IProjectTemplatesService {
2323
const templateNameParts = this.$npm.getPackageNameParts(templateValue);
2424
templateValue = constants.RESERVED_TEMPLATE_NAMES[templateNameParts.name] || templateNameParts.name;
2525

26-
let version = templateNameParts.version || await this.$npmInstallationManager.getLatestCompatibleVersionSafe(templateValue);
26+
const version = templateNameParts.version || await this.$npmInstallationManager.getLatestCompatibleVersionSafe(templateValue);
2727
const fullTemplateName = this.$npm.getPackageFullName({ name: templateValue, version: version });
2828

2929
const templatePackageJsonContent = await this.getTemplatePackageJsonContent(fullTemplateName);

test/node-package-manager.ts

+75-75
Original file line numberDiff line numberDiff line change
@@ -5,84 +5,84 @@ import { NodePackageManager } from "../lib/node-package-manager";
55

66
function createTestInjector(configuration: {
77
} = {}): IInjector {
8-
const injector = new Yok();
9-
injector.register("hostInfo", {});
10-
injector.register("errors", stubs.ErrorsStub);
11-
injector.register("logger", stubs.LoggerStub);
12-
injector.register("childProcess", stubs.ChildProcessStub);
13-
injector.register("httpClient", {});
14-
injector.register("fs", stubs.FileSystemStub);
15-
injector.register("npm", NodePackageManager);
8+
const injector = new Yok();
9+
injector.register("hostInfo", {});
10+
injector.register("errors", stubs.ErrorsStub);
11+
injector.register("logger", stubs.LoggerStub);
12+
injector.register("childProcess", stubs.ChildProcessStub);
13+
injector.register("httpClient", {});
14+
injector.register("fs", stubs.FileSystemStub);
15+
injector.register("npm", NodePackageManager);
1616

17-
return injector;
17+
return injector;
1818
}
1919

20-
describe.only("node-package-manager", () => {
20+
describe("node-package-manager", () => {
2121

22-
describe("getPackageNameParts", () => {
23-
[
24-
{
25-
name: "should return both name and version when valid fullName passed",
26-
templateFullName: "[email protected]",
27-
expectedVersion: "1.0.0",
28-
expectedName: "some-template",
29-
},
30-
{
31-
name: "should return both name and version when valid fullName with scope passed",
32-
templateFullName: "@nativescript/[email protected]",
33-
expectedVersion: "1.0.0",
34-
expectedName: "@nativescript/some-template",
35-
},
36-
{
37-
name: "should return only name when version is not specified and the template is scoped",
38-
templateFullName: "@nativescript/some-template",
39-
expectedVersion: "",
40-
expectedName: "@nativescript/some-template",
41-
},
42-
{
43-
name: "should return only name when version is not specified",
44-
templateFullName: "some-template",
45-
expectedVersion: "",
46-
expectedName: "some-template",
47-
}
48-
].forEach(testCase => {
49-
it(testCase.name, async () => {
50-
const testInjector = createTestInjector();
51-
const npm = testInjector.resolve<NodePackageManager>("npm");
52-
const templateNameParts = await npm.getPackageNameParts(testCase.templateFullName);
53-
assert.strictEqual(templateNameParts.name, testCase.expectedName);
54-
assert.strictEqual(templateNameParts.version, testCase.expectedVersion);
55-
});
56-
});
57-
});
22+
describe("getPackageNameParts", () => {
23+
[
24+
{
25+
name: "should return both name and version when valid fullName passed",
26+
templateFullName: "[email protected]",
27+
expectedVersion: "1.0.0",
28+
expectedName: "some-template",
29+
},
30+
{
31+
name: "should return both name and version when valid fullName with scope passed",
32+
templateFullName: "@nativescript/[email protected]",
33+
expectedVersion: "1.0.0",
34+
expectedName: "@nativescript/some-template",
35+
},
36+
{
37+
name: "should return only name when version is not specified and the template is scoped",
38+
templateFullName: "@nativescript/some-template",
39+
expectedVersion: "",
40+
expectedName: "@nativescript/some-template",
41+
},
42+
{
43+
name: "should return only name when version is not specified",
44+
templateFullName: "some-template",
45+
expectedVersion: "",
46+
expectedName: "some-template",
47+
}
48+
].forEach(testCase => {
49+
it(testCase.name, async () => {
50+
const testInjector = createTestInjector();
51+
const npm = testInjector.resolve<NodePackageManager>("npm");
52+
const templateNameParts = await npm.getPackageNameParts(testCase.templateFullName);
53+
assert.strictEqual(templateNameParts.name, testCase.expectedName);
54+
assert.strictEqual(templateNameParts.version, testCase.expectedVersion);
55+
});
56+
});
57+
});
5858

59-
describe("getPackageFullName", () => {
60-
[
61-
{
62-
name: "should return name and version when specified",
63-
templateName: "some-template",
64-
templateVersion: "1.0.0",
65-
expectedFullName: "[email protected]",
66-
},
67-
{
68-
name: "should return only the github url when no version specified",
69-
templateName: "https://github.com/NativeScript/template-drawer-navigation-ng#master",
70-
templateVersion: "",
71-
expectedFullName: "https://github.com/NativeScript/template-drawer-navigation-ng#master",
72-
},
73-
{
74-
name: "should return only the name when no version specified",
75-
templateName: "some-template",
76-
templateVersion: "",
77-
expectedFullName: "some-template",
78-
}
79-
].forEach(testCase => {
80-
it(testCase.name, async () => {
81-
const testInjector = createTestInjector();
82-
const npm = testInjector.resolve<NodePackageManager>("npm");
83-
const templateFullName = await npm.getPackageFullName({ name: testCase.templateName, version: testCase.templateVersion });
84-
assert.strictEqual(templateFullName, testCase.expectedFullName);
85-
});
86-
});
87-
});
59+
describe("getPackageFullName", () => {
60+
[
61+
{
62+
name: "should return name and version when specified",
63+
templateName: "some-template",
64+
templateVersion: "1.0.0",
65+
expectedFullName: "[email protected]",
66+
},
67+
{
68+
name: "should return only the github url when no version specified",
69+
templateName: "https://github.com/NativeScript/template-drawer-navigation-ng#master",
70+
templateVersion: "",
71+
expectedFullName: "https://github.com/NativeScript/template-drawer-navigation-ng#master",
72+
},
73+
{
74+
name: "should return only the name when no version specified",
75+
templateName: "some-template",
76+
templateVersion: "",
77+
expectedFullName: "some-template",
78+
}
79+
].forEach(testCase => {
80+
it(testCase.name, async () => {
81+
const testInjector = createTestInjector();
82+
const npm = testInjector.resolve<NodePackageManager>("npm");
83+
const templateFullName = await npm.getPackageFullName({ name: testCase.templateName, version: testCase.templateVersion });
84+
assert.strictEqual(templateFullName, testCase.expectedFullName);
85+
});
86+
});
87+
});
8888
});

test/project-templates-service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ let isDeleteDirectoryCalledForNodeModulesDir = false;
1010
const nativeScriptValidatedTemplatePath = "nsValidatedTemplatePath";
1111
const compatibleTemplateVersion = "1.2.3";
1212

13-
1413
function createTestInjector(configuration: {
1514
shouldNpmInstallThrow?: boolean,
1615
packageJsonContent?: any,
@@ -44,7 +43,7 @@ function createTestInjector(configuration: {
4443
return {
4544
name: configuration.packageName || fullPackageName,
4645
version: configuration.packageVersion || ""
47-
}
46+
};
4847
}
4948
}
5049

test/stubs.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export class NodePackageManagerStub implements INodePackageManager {
279279
return {
280280
name: fullPackageName,
281281
version: ""
282-
}
282+
};
283283
}
284284

285285
public getPackageFullName(packageNameParts: INpmPackageNameParts): string {
@@ -291,7 +291,7 @@ export class NodePackageManagerStub implements INodePackageManager {
291291
}
292292

293293
public async getRegistryPackageData(packageName: string): Promise<any> {
294-
return null
294+
return null;
295295
}
296296

297297
public async getCachePath(): Promise<string> {

0 commit comments

Comments
 (0)