Path join (#92)

This commit is contained in:
Shohei Ueda 2019-11-22 11:14:44 +09:00 committed by GitHub
parent 1490c6e417
commit ef869fb22f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 6 deletions

View File

@ -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);

View File

@ -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`;
}