Path join (#92)
This commit is contained in:
parent
1490c6e417
commit
ef869fb22f
26
lib/index.js
26
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);
|
||||
|
|
|
@ -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`;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue