Skip to content

Commit

Permalink
workaround for #91
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka committed Nov 5, 2023
1 parent f5ff338 commit 9781783
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
25 changes: 23 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const core = __nccwpck_require__(2186);
const io = __nccwpck_require__(7436);
const tools = __nccwpck_require__(7784);
const path = __nccwpck_require__(1017);
const fs = __nccwpck_require__(7147);
const semver_1 = __nccwpck_require__(1383);
const catalog = __nccwpck_require__(5284);
const shared = __nccwpck_require__(6946);
Expand Down Expand Up @@ -261,16 +262,36 @@ class ToolsGetter {
restoreCache(outPath, key) {
return cache.restoreCache([outPath], key.toString());
}
extract(archiveSuffix, downloaded, outputPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield extractFunction[archiveSuffix](downloaded, outputPath);
}
catch (exception) {
// Fix up the path for https://github.com/actions/toolkit/issues/1179
if (process.platform === 'win32') {
const zipExtension = ".zip";
if (path.extname(downloaded) !== zipExtension) {
const downloadedZip = downloaded + zipExtension;
fs.renameSync(downloaded, downloadedZip);
return yield extractFunction[archiveSuffix](downloadedZip, outputPath);
}
}
throw exception;
}
return downloaded;
});
}
downloadTools(cmakePackage, ninjaPackage, outputPath) {
return __awaiter(this, void 0, void 0, function* () {
let outPath;
yield core.group("Downloading and extracting CMake", () => __awaiter(this, void 0, void 0, function* () {
const downloaded = yield tools.downloadTool(cmakePackage.url);
yield extractFunction[cmakePackage.dropSuffix](downloaded, outputPath);
yield this.extract(cmakePackage.dropSuffix, downloaded, outputPath);
}));
yield core.group("Downloading and extracting Ninja", () => __awaiter(this, void 0, void 0, function* () {
const downloaded = yield tools.downloadTool(ninjaPackage.url);
yield extractFunction[ninjaPackage.dropSuffix](downloaded, outputPath);
yield this.extract(ninjaPackage.dropSuffix, downloaded, outputPath);
}));
});
}
Expand Down
25 changes: 23 additions & 2 deletions src/get-cmake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as core from '@actions/core';
import * as io from '@actions/io';
import * as tools from '@actions/tool-cache';
import * as path from 'path';
import * as fs from 'fs';
import { SemVer, maxSatisfying } from 'semver';
import * as catalog from './releases-catalog'
import * as shared from './releases-collector'
Expand Down Expand Up @@ -256,18 +257,38 @@ export class ToolsGetter {
return cache.restoreCache([outPath], key.toString());
}

private async extract(archiveSuffix: string, downloaded: string, outputPath: string): Promise<string> {
try {
await extractFunction[archiveSuffix](downloaded, outputPath);
} catch (exception) {
// Fix up the downloaded archive extension for https://github.com/actions/toolkit/issues/1179
if (process.platform === 'win32') {
const zipExtension = ".zip";
if (path.extname(downloaded) !== zipExtension) {
const downloadedZip = downloaded + zipExtension;
fs.renameSync(downloaded, downloadedZip);
return await extractFunction[archiveSuffix](downloadedZip, outputPath);
}
}

throw exception;
}

return downloaded;
}

private async downloadTools(
cmakePackage: shared.PackageInfo, ninjaPackage: shared.PackageInfo,
outputPath: string): Promise<void> {
let outPath: string;
await core.group("Downloading and extracting CMake", async () => {
const downloaded = await tools.downloadTool(cmakePackage.url);
await extractFunction[cmakePackage.dropSuffix](downloaded, outputPath);
await this.extract(cmakePackage.dropSuffix, downloaded, outputPath);
});

await core.group("Downloading and extracting Ninja", async () => {
const downloaded = await tools.downloadTool(ninjaPackage.url);
await extractFunction[ninjaPackage.dropSuffix](downloaded, outputPath);
await this.extract(ninjaPackage.dropSuffix, downloaded, outputPath);
});
}

Expand Down

0 comments on commit 9781783

Please sign in to comment.