diff --git a/lib/index.js b/lib/index.js index 1d462c6..6ca74b3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5153,6 +5153,18 @@ const tc = __importStar(__webpack_require__(533)); const io = __importStar(__webpack_require__(1)); const get_os_1 = __importDefault(__webpack_require__(443)); const get_url_1 = __importDefault(__webpack_require__(901)); +const path = __importStar(__webpack_require__(622)); +let tempDir = process.env['RUNNER_TEMPDIRECTORY'] || ''; +if (!tempDir) { + let baseTempLocation; + if (process.platform === 'win32') { + baseTempLocation = process.env['USERPROFILE'] || 'C:\\'; + } + else { + baseTempLocation = `${process.env.HOME}`; + } + tempDir = path.join(baseTempLocation, 'tmp'); +} function installer(version) { return __awaiter(this, void 0, void 0, function* () { try { @@ -5162,17 +5174,25 @@ function installer(version) { console.log(`Operating System: ${osName}`); const hugoURL = get_url_1.default(osName, extended, version); core.debug(`hugoURL: ${hugoURL}`); - const hugoPath = `${process.env.HOME}/bin`; + let baseLocation; + if (process.platform === 'win32') { + baseLocation = process.env['USERPROFILE'] || 'C:\\'; + } + else { + baseLocation = `${process.env.HOME}`; + } + const hugoPath = path.join(baseLocation, 'hugobin'); yield io.mkdirP(hugoPath); core.addPath(hugoPath); + yield io.mkdirP(tempDir); const hugoAssets = yield tc.downloadTool(hugoURL); let hugoBin = ''; if (osName === 'Windows') { - const hugoExtractedFolder = yield tc.extractZip(hugoAssets, '/tmp'); + const hugoExtractedFolder = yield tc.extractZip(hugoAssets, tempDir); hugoBin = `${hugoExtractedFolder}/hugo.exe`; } else { - const hugoExtractedFolder = yield tc.extractTar(hugoAssets, '/tmp'); + const hugoExtractedFolder = yield tc.extractTar(hugoAssets, tempDir); hugoBin = `${hugoExtractedFolder}/hugo`; } yield io.mv(hugoBin, hugoPath); diff --git a/package-lock.json b/package-lock.json index 419cd3a..db473dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -566,9 +566,9 @@ "dev": true }, "@types/node": { - "version": "12.12.8", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.8.tgz", - "integrity": "sha512-XLla8N+iyfjvsa0KKV+BP/iGSoTmwxsu5Ci5sM33z9TjohF72DEz95iNvD6pPmemvbQgxAv/909G73gUn8QR7w==", + "version": "12.12.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz", + "integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==", "dev": true }, "@types/normalize-package-data": { @@ -599,36 +599,37 @@ "dev": true }, "@typescript-eslint/experimental-utils": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.7.0.tgz", - "integrity": "sha512-9/L/OJh2a5G2ltgBWJpHRfGnt61AgDeH6rsdg59BH0naQseSwR7abwHq3D5/op0KYD/zFT4LS5gGvWcMmegTEg==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.8.0.tgz", + "integrity": "sha512-jZ05E4SxCbbXseQGXOKf3ESKcsGxT8Ucpkp1jiVp55MGhOvZB2twmWKf894PAuVQTCgbPbJz9ZbRDqtUWzP8xA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.7.0", + "@typescript-eslint/typescript-estree": "2.8.0", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.7.0.tgz", - "integrity": "sha512-ctC0g0ZvYclxMh/xI+tyqP0EC2fAo6KicN9Wm2EIao+8OppLfxji7KAGJosQHSGBj3TcqUrA96AjgXuKa5ob2g==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.8.0.tgz", + "integrity": "sha512-NseXWzhkucq+JM2HgqAAoKEzGQMb5LuTRjFPLQzGIdLthXMNUfuiskbl7QSykvWW6mvzCtYbw1fYWGa2EIaekw==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.7.0", - "@typescript-eslint/typescript-estree": "2.7.0", + "@typescript-eslint/experimental-utils": "2.8.0", + "@typescript-eslint/typescript-estree": "2.8.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.7.0.tgz", - "integrity": "sha512-vVCE/DY72N4RiJ/2f10PTyYekX2OLaltuSIBqeHYI44GQ940VCYioInIb8jKMrK9u855OEJdFC+HmWAZTnC+Ag==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.8.0.tgz", + "integrity": "sha512-ksvjBDTdbAQ04cR5JyFSDX113k66FxH1tAXmi+dj6hufsl/G0eMc/f1GgLjEVPkYClDbRKv+rnBFuE5EusomUw==", "dev": true, "requires": { "debug": "^4.1.1", - "glob": "^7.1.4", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", "is-glob": "^4.0.1", "lodash.unescape": "4.0.1", "semver": "^6.3.0", @@ -644,6 +645,20 @@ "ms": "^2.1.1" } }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -3045,9 +3060,9 @@ } }, "husky": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/husky/-/husky-3.0.9.tgz", - "integrity": "sha512-Yolhupm7le2/MqC1VYLk/cNmYxsSsqKkTyBhzQHhPK1jFnC89mmmNVuGtLNabjDI6Aj8UNIr0KpRNuBkiC4+sg==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/husky/-/husky-3.1.0.tgz", + "integrity": "sha512-FJkPoHHB+6s4a+jwPqBudBDvYZsoQW5/HBuMSehC8qDiCe50kpcxeqFoDSlow+9I6wg47YxBoT3WxaURlrDIIQ==", "dev": true, "requires": { "chalk": "^2.4.2", diff --git a/package.json b/package.json index 090f7e4..5f72e8e 100644 --- a/package.json +++ b/package.json @@ -54,11 +54,11 @@ }, "devDependencies": { "@types/jest": "^24.0.23", - "@types/node": "^12.12.8", - "@typescript-eslint/parser": "^2.7.0", + "@types/node": "^12.12.11", + "@typescript-eslint/parser": "^2.8.0", "@zeit/ncc": "^0.20.5", "eslint": "^6.6.0", - "husky": "^3.0.9", + "husky": "^3.1.0", "jest": "^24.9.0", "jest-circus": "^24.9.0", "lint-staged": "^9.4.3", diff --git a/src/installer.ts b/src/installer.ts index 517f4ef..e2513a4 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -3,6 +3,18 @@ import * as tc from '@actions/tool-cache'; import * as io from '@actions/io'; import getOS from './get-os'; import getURL from './get-url'; +import * as path from 'path'; + +let tempDir: string = process.env['RUNNER_TEMPDIRECTORY'] || ''; +if (!tempDir) { + let baseTempLocation: string; + if (process.platform === 'win32') { + baseTempLocation = process.env['USERPROFILE'] || 'C:\\'; + } else { + baseTempLocation = `${process.env.HOME}`; + } + tempDir = path.join(baseTempLocation, 'tmp'); +} export default async function installer(version: string) { try { @@ -15,23 +27,30 @@ export default async function installer(version: string) { const hugoURL: string = getURL(osName, extended, version); core.debug(`hugoURL: ${hugoURL}`); - const hugoPath: string = `${process.env.HOME}/bin`; + let baseLocation: string; + if (process.platform === 'win32') { + baseLocation = process.env['USERPROFILE'] || 'C:\\'; + } else { + baseLocation = `${process.env.HOME}`; + } + const hugoPath: string = path.join(baseLocation, 'hugobin'); await io.mkdirP(hugoPath); core.addPath(hugoPath); // Download and extract Hugo binary + await io.mkdirP(tempDir); const hugoAssets: string = await tc.downloadTool(hugoURL); let hugoBin: string = ''; if (osName === 'Windows') { const hugoExtractedFolder: string = await tc.extractZip( hugoAssets, - '/tmp' + tempDir ); hugoBin = `${hugoExtractedFolder}/hugo.exe`; } else { const hugoExtractedFolder: string = await tc.extractTar( hugoAssets, - '/tmp' + tempDir ); hugoBin = `${hugoExtractedFolder}/hugo`; }