feat: Add getOS()

This commit is contained in:
peaceiris 2019-09-18 09:59:07 +09:00
parent 4b6109cfb2
commit 86eb62d73e
5 changed files with 35 additions and 26 deletions

13
lib/get-os.js Normal file
View file

@ -0,0 +1,13 @@
function getOS(platform) {
if (platform === "linux") {
return "Linux";
} else if (platform === "darwin") {
return "macOS";
} else if (platform === "win32") {
throw new Error("Windows is not supported");
} else {
throw new Error(`${platform} is not supported`);
}
}
module.exports = getOS;

View file

@ -2,6 +2,7 @@ const core = require("@actions/core");
const tc = require("@actions/tool-cache");
const io = require("@actions/io");
const exec = require("@actions/exec");
const getOS = require("./get-os");
const getLatestVersion = require("./get-latest-version");
// most @actions toolkit packages have async methods
@ -22,9 +23,10 @@ async function run() {
extendedStr = "extended_";
}
console.log(`Operating System: ${process.platform}`);
const osName = getOS(process.platform);
console.log(`Operating System: ${osName}`);
const hugoName = `hugo_${extendedStr}${hugoVersion}_Linux-64bit`;
const hugoName = `hugo_${extendedStr}${hugoVersion}_${osName}-64bit`;
core.debug(`hugoName: ${hugoName}`);
const hugoURL = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/${hugoName}.tar.gz`;