Skip to content

Commit

Permalink
fix tslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Kalyvitis committed Jun 18, 2020
1 parent ff8fe44 commit 3ff198f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lib/setup-tools.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/setup-tools.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions lib/setup-tools.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/setup-tools.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions src/setup-tools.test.ts
Original file line number Diff line number Diff line change
@@ -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 => {

Expand Down Expand Up @@ -36,7 +36,7 @@ test('download codeql bundle cache', async t => {

t.is(cachedVersions.length, 2);
});
})
});

test('parse codeql bundle url version', t => {

Expand All @@ -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);
}
}
}
});
});
12 changes: 6 additions & 6 deletions src/setup-tools.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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`);
Expand All @@ -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;
}
}

0 comments on commit 3ff198f

Please sign in to comment.