Skip to content

Commit

Permalink
debug: installer
Browse files Browse the repository at this point in the history
  • Loading branch information
rumblefrog committed Nov 15, 2019
1 parent ca0c4b0 commit 0c9da3d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const installer_1 = require("./installer");
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const range = core.getInput('version');
const range = core.getInput('version', { required: true });
let version = yield installer_1.installCompiler(range);
core.setOutput('version', version);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function installCompiler(range) {
if (!cache) {
cache = yield downloadCompiler(version);
}
core_1.debug(`${cache} was added to path`);
core_1.addPath(cache);
return version;
});
Expand All @@ -34,6 +35,7 @@ exports.installCompiler = installCompiler;
function downloadCompiler(version) {
return __awaiter(this, void 0, void 0, function* () {
const spPath = yield tool_cache_1.downloadTool(versions[version].toEndpoint());
core_1.debug(`${versions[version].toEndpoint()} was downloaded`);
let extracted;
if (process.platform === 'linux') {
extracted = yield tool_cache_1.extractTar(spPath);
Expand All @@ -42,6 +44,7 @@ function downloadCompiler(version) {
extracted = yield tool_cache_1.extractZip(spPath);
}
let spRoot = path_1.join(extracted, 'addons', 'sourcemod', 'scripting');
core_1.debug(`${spRoot} was added to tool cache`);
return yield tool_cache_1.cacheDir(spRoot, 'sourcepawn', version);
});
}
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { installCompiler } from './installer';

async function run() {
try {
const range = core.getInput('version');
const range = core.getInput('version', { required: true });

let version = await installCompiler(range);
core.setOutput('version', version);
Expand Down
8 changes: 7 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { find as findCache, downloadTool, extractTar, extractZip, cacheDir } from '@actions/tool-cache';
import { addPath } from '@actions/core';
import { addPath, debug } from '@actions/core';
import { maxSatisfying } from 'semver';
import { join as pathJoin } from 'path';
import { getVersions } from './scraper';
Expand All @@ -21,13 +21,17 @@ export async function installCompiler(range: string): Promise<string> {
cache = await downloadCompiler(version);
}

debug(`${cache} was added to path`);

addPath(cache);

return version;
}

async function downloadCompiler(version: string) {
const spPath = await downloadTool(versions[version].toEndpoint());

debug(`${versions[version].toEndpoint()} was downloaded`);

let extracted;

Expand All @@ -39,5 +43,7 @@ async function downloadCompiler(version: string) {

let spRoot = pathJoin(extracted, 'addons', 'sourcemod', 'scripting');

debug(`${spRoot} was added to tool cache`);

return await cacheDir(spRoot, 'sourcepawn', version);
}

0 comments on commit 0c9da3d

Please sign in to comment.