fix tslint errors

This commit is contained in:
Alex Kalyvitis 2020-06-18 18:29:25 +02:00
parent ff8fe44e0c
commit 3ff198f23b
6 changed files with 39 additions and 35 deletions

View file

@ -1,10 +1,10 @@
import test from 'ava';
import * as path from 'path';
import * as toolcache from '@actions/tool-cache';
import * as util from './util';
import test from 'ava';
import nock from 'nock';
import * as path from 'path';
import * as setupTools from './setup-tools';
import * as util from './util';
test('download codeql bundle cache', async t => {
@ -36,7 +36,7 @@ test('download codeql bundle cache', async t => {
t.is(cachedVersions.length, 2);
});
})
});
test('parse codeql bundle url version', t => {
@ -50,15 +50,17 @@ test('parse codeql bundle url version', t => {
};
for (const version in tests) {
if (tests.hasOwnProperty(version)) {
const expectedVersion = tests[version];
const url = `https://github.com/.../codeql-bundle-${version}/...`;
const expectedVersion = tests[version];
const url = `https://github.com/.../codeql-bundle-${version}/...`;
try {
const parsedVersion = setupTools.getCodeQLURLVersion(url);
t.assert(parsedVersion, expectedVersion);
} catch (e) {
t.fail(e.message);
try {
const parsedVersion = setupTools.getCodeQLURLVersion(url);
t.assert(parsedVersion, expectedVersion);
} catch (e) {
t.fail(e.message);
}
}
}
});
});

View file

@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as toolcache from '@actions/tool-cache';
import * as semver from 'semver';
import * as path from 'path';
import * as semver from 'semver';
export class CodeQLSetup {
public dist: string;
@ -32,7 +32,7 @@ export class CodeQLSetup {
export async function setupCodeQL(): Promise<CodeQLSetup> {
try {
const codeqlURL = core.getInput('tools', { required: true });
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL);
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL);
let codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
if (codeqlFolder) {
@ -51,7 +51,7 @@ export async function setupCodeQL(): Promise<CodeQLSetup> {
}
export function getCodeQLURLVersion(url: string): string {
const match = url.match(/codeql-bundle-([\d+(\.\d+)]+)/);
if (match === null || match.length < 2) {
throw new Error(`Malformed tools url: ${url}. Version could not be inferred`);
@ -61,13 +61,13 @@ export function getCodeQLURLVersion(url: string): string {
if (!semver.valid(version)) {
core.debug(`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`);
version = '0.0.0-' + version;
version = '0.0.0-' + version;
}
const s = semver.clean(version);
if (!s) {
throw new Error(`Malformed tools url ${url}. Version should be in SemVer format but have ${version} instead`);
}
return s;
}
}