mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-24 10:47:28 +01:00
Path join (#92)
This commit is contained in:
@@ -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`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user