run linter

This commit is contained in:
Roberto Sora
2019-10-25 14:47:12 +02:00
parent e9f8b4275e
commit ac9c8a4eae
3 changed files with 36 additions and 38 deletions

View File

@@ -31,7 +31,7 @@ describe("installer tests", () => {
});
it("Downloads version of Task if no matching version is installed", async () => {
await installer.getTask("2.6.0","");
await installer.getTask("2.6.0", "");
const taskDir = path.join(toolDir, "task", "2.6.0", os.arch());
expect(fs.existsSync(`${taskDir}.complete`)).toBe(true);
@@ -56,7 +56,7 @@ describe("installer tests", () => {
});
it("Gets the latest version of Task 2.5 using 2.5 and no matching version is installed", async () => {
await installer.getTask("2.5","");
await installer.getTask("2.5", "");
const taskDir = path.join(toolDir, "task", "2.5.2", os.arch());
expect(fs.existsSync(`${taskDir}.complete`)).toBe(true);
@@ -68,7 +68,7 @@ describe("installer tests", () => {
});
it("Gets latest version of Task using 2.x and no matching version is installed", async () => {
await installer.getTask("2.x","");
await installer.getTask("2.x", "");
const taskdir = path.join(toolDir, "task", "2.6.0", os.arch());
expect(fs.existsSync(`${taskdir}.complete`)).toBe(true);
@@ -80,7 +80,7 @@ describe("installer tests", () => {
});
it("Gets preview version of Task using 3.x and no matching version is installed", async () => {
await installer.getTask("3.x","");
await installer.getTask("3.x", "");
const taskdir = path.join(toolDir, "task", "3.0.0-preview1", os.arch());
expect(fs.existsSync(`${taskdir}.complete`)).toBe(true);

33
package-lock.json generated
View File

@@ -1135,9 +1135,9 @@
}
},
"commander": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"dev": true,
"optional": true
},
@@ -1766,8 +1766,7 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"aproba": {
"version": "1.2.0",
@@ -2182,8 +2181,7 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
@@ -2239,7 +2237,6 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@@ -2283,14 +2280,12 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true,
"optional": true
"dev": true
}
}
},
@@ -2369,9 +2364,9 @@
"dev": true
},
"handlebars": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz",
"integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==",
"version": "4.4.5",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.5.tgz",
"integrity": "sha512-0Ce31oWVB7YidkaTq33ZxEbN+UDxMMgThvCe8ptgQViymL5DPis9uLdTA13MiRPhgvqyxIegugrP97iK3JeBHg==",
"dev": true,
"requires": {
"neo-async": "^2.6.0",
@@ -5089,13 +5084,13 @@
"dev": true
},
"uglify-js": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz",
"integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==",
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.4.tgz",
"integrity": "sha512-9Yc2i881pF4BPGhjteCXQNaXx1DCwm3dtOyBaG2hitHjLWOczw/ki8vD1bqyT3u6K0Ms/FpCShkmfg+FtlOfYA==",
"dev": true,
"optional": true,
"requires": {
"commander": "~2.20.0",
"commander": "~2.20.3",
"source-map": "~0.6.1"
}
},

View File

@@ -33,7 +33,7 @@ interface ITaskRef {
ref: string;
}
export async function getTask(version: string, repoToken: string) {
export async function getTask(version: string, repoToken: string) {
// resolve the version number
const targetVersion = await computeVersion(version, repoToken);
if (targetVersion) {
@@ -61,7 +61,7 @@ async function downloadRelease(version: string): Promise<string> {
"https://github.com/go-task/task/releases/download/%s/%s",
version,
fileName
);
);
let downloadPath: string | null = null;
try {
downloadPath = await tc.downloadTool(downloadUrl);
@@ -109,17 +109,20 @@ async function fetchVersions(repoToken: string): Promise<string[]> {
}
let tags: ITaskRef[] =
(await rest.get<ITaskRef[]>(
"https://api.github.com/repos/go-task/task/git/refs/tags"
(await rest.get<ITaskRef[]>(
"https://api.github.com/repos/go-task/task/git/refs/tags"
)).result || [];
return tags
.filter(tag => tag.ref.match(/v\d+\.[\w\.]+/g))
.map(tag => tag.ref.replace("refs/tags/v", ""));
.filter(tag => tag.ref.match(/v\d+\.[\w\.]+/g))
.map(tag => tag.ref.replace("refs/tags/v", ""));
}
// Compute an actual version starting from the `version` configuration param.
async function computeVersion(version: string, repoToken: string): Promise<string> {
async function computeVersion(
version: string,
repoToken: string
): Promise<string> {
// strip leading `v` char (will be re-added later)
if (version.startsWith("v")) {
version = version.slice(1, version.length);
@@ -137,8 +140,8 @@ async function computeVersion(version: string, repoToken: string): Promise<strin
possibleVersions.forEach(v => versionMap.set(normalizeVersion(v), v));
const versions = Array.from(versionMap.keys())
.sort(semver.rcompare)
.map(v => versionMap.get(v));
.sort(semver.rcompare)
.map(v => versionMap.get(v));
core.debug(`evaluating ${versions.length} versions`);
@@ -165,9 +168,9 @@ function normalizeVersion(version: string): string {
// e.g. 1.10beta1 -? 1.10.0-beta1, 1.10rc1 -> 1.10.0-rc1
if (preStrings.some(el => versionPart[1].includes(el))) {
versionPart[1] = versionPart[1]
.replace("beta", ".0-beta")
.replace("rc", ".0-rc")
.replace("preview", ".0-preview");
.replace("beta", ".0-beta")
.replace("rc", ".0-rc")
.replace("preview", ".0-preview");
return versionPart.join(".");
}
}
@@ -181,9 +184,9 @@ function normalizeVersion(version: string): string {
// e.g. 1.8.5beta1 -> 1.8.5-beta1, 1.8.5rc1 -> 1.8.5-rc1
if (preStrings.some(el => versionPart[2].includes(el))) {
versionPart[2] = versionPart[2]
.replace("beta", "-beta")
.replace("rc", "-rc")
.replace("preview", "-preview");
.replace("beta", "-beta")
.replace("rc", "-rc")
.replace("preview", "-preview");
return versionPart.join(".");
}
}