refactor: enhance error handling
This commit is contained in:
parent
67d5fb9f50
commit
8df3468b4d
4 changed files with 54 additions and 33 deletions
|
|
@ -5,30 +5,34 @@ const getOS = require("./get-os");
|
|||
const getURL = require("./get-url");
|
||||
|
||||
async function installer(version) {
|
||||
const extended = core.getInput("extended");
|
||||
console.log(`Hugo extended: ${extended}`);
|
||||
try {
|
||||
const extended = core.getInput("extended");
|
||||
console.log(`Hugo extended: ${extended}`);
|
||||
|
||||
const osName = getOS(process.platform);
|
||||
console.log(`Operating System: ${osName}`);
|
||||
const osName = getOS(process.platform);
|
||||
console.log(`Operating System: ${osName}`);
|
||||
|
||||
const hugoURL = getURL(osName, extended, version);
|
||||
core.debug(`hugoURL: ${hugoURL}`);
|
||||
const hugoURL = getURL(osName, extended, version);
|
||||
core.debug(`hugoURL: ${hugoURL}`);
|
||||
|
||||
const hugoPath = `${process.env.HOME}/bin`;
|
||||
await io.mkdirP(hugoPath);
|
||||
core.addPath(hugoPath);
|
||||
const hugoPath = `${process.env.HOME}/bin`;
|
||||
await io.mkdirP(hugoPath);
|
||||
core.addPath(hugoPath);
|
||||
|
||||
// Download and extract Hugo binary
|
||||
const hugoAssets = await tc.downloadTool(hugoURL);
|
||||
let hugoBin = "";
|
||||
if (osName === "Windows") {
|
||||
const hugoExtractedFolder = await tc.extractZip(hugoAssets, "/tmp");
|
||||
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
|
||||
} else {
|
||||
const hugoExtractedFolder = await tc.extractTar(hugoAssets, "/tmp");
|
||||
hugoBin = `${hugoExtractedFolder}/hugo`;
|
||||
// Download and extract Hugo binary
|
||||
const hugoAssets = await tc.downloadTool(hugoURL);
|
||||
let hugoBin = "";
|
||||
if (osName === "Windows") {
|
||||
const hugoExtractedFolder = await tc.extractZip(hugoAssets, "/tmp");
|
||||
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
|
||||
} else {
|
||||
const hugoExtractedFolder = await tc.extractTar(hugoAssets, "/tmp");
|
||||
hugoBin = `${hugoExtractedFolder}/hugo`;
|
||||
}
|
||||
await io.mv(hugoBin, hugoPath);
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
await io.mv(hugoBin, hugoPath);
|
||||
}
|
||||
|
||||
module.exports = installer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue