style: 💄 Fix format
This commit is contained in:
parent
286eb0a87e
commit
1554388ab7
5 changed files with 42 additions and 41 deletions
|
|
@ -1,11 +1,11 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
|
||||
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
|
||||
function getLatestVersion() {
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const url = "https://formulae.brew.sh/api/formula/hugo.json";
|
||||
xhr.open("GET", url);
|
||||
const url = 'https://formulae.brew.sh/api/formula/hugo.json';
|
||||
xhr.open('GET', url);
|
||||
xhr.send();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function getOS(platform) {
|
||||
if (platform === "linux") {
|
||||
return "Linux";
|
||||
if (platform === 'linux') {
|
||||
return 'Linux';
|
||||
}
|
||||
else if (platform === "darwin") {
|
||||
return "macOS";
|
||||
else if (platform === 'darwin') {
|
||||
return 'macOS';
|
||||
}
|
||||
else if (platform === "win32") {
|
||||
return "Windows";
|
||||
else if (platform === 'win32') {
|
||||
return 'Windows';
|
||||
// throw new Error("Windows is not supported");
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -2,25 +2,25 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function getURL(os, extended, version) {
|
||||
const extendedStr = (extended) => {
|
||||
if (extended === "true") {
|
||||
return "extended_";
|
||||
if (extended === 'true') {
|
||||
return 'extended_';
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
return '';
|
||||
// } else {
|
||||
// throw new Error(`Invalid input (extended): ${extended}`);
|
||||
}
|
||||
};
|
||||
const ext = (os) => {
|
||||
if (os === "Windows") {
|
||||
return "zip";
|
||||
if (os === 'Windows') {
|
||||
return 'zip';
|
||||
}
|
||||
else {
|
||||
return "tar.gz";
|
||||
return 'tar.gz';
|
||||
}
|
||||
};
|
||||
const hugoName = `hugo_${extendedStr(extended)}${version}_${os}-64bit`;
|
||||
const baseURL = "https://github.com/gohugoio/hugo/releases/download";
|
||||
const baseURL = 'https://github.com/gohugoio/hugo/releases/download';
|
||||
const url = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
|
||||
return url;
|
||||
}
|
||||
|
|
|
|||
41
lib/index.js
41
lib/index.js
|
|
@ -26,28 +26,29 @@ const installer_1 = __importDefault(require("./installer"));
|
|||
// most @actions toolkit packages have async methods
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const dump = () => __awaiter(this, void 0, void 0, function* () {
|
||||
// Show version
|
||||
yield exec.exec('hugo version');
|
||||
yield exec.exec('go version');
|
||||
yield exec.exec('git --version');
|
||||
});
|
||||
try {
|
||||
get_latest_version_1.default().then(function (latestVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const hugoVersion = core.getInput("hugo-version");
|
||||
console.log(`Hugo version: ${hugoVersion}`);
|
||||
const version = (v, latestVersion) => {
|
||||
if (v === "" || v === "latest") {
|
||||
return latestVersion;
|
||||
}
|
||||
else {
|
||||
return v;
|
||||
}
|
||||
};
|
||||
yield installer_1.default(version(hugoVersion, latestVersion));
|
||||
// Show version
|
||||
yield exec.exec("hugo version");
|
||||
yield exec.exec("go version");
|
||||
yield exec.exec("git --version");
|
||||
const hugoVersion = core.getInput('hugo-version');
|
||||
console.log(`Hugo version: ${hugoVersion}`);
|
||||
if (hugoVersion === '' || hugoVersion === 'latest') {
|
||||
get_latest_version_1.default().then(function (latestVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield installer_1.default(latestVersion);
|
||||
yield dump();
|
||||
});
|
||||
}, function (error) {
|
||||
core.setFailed(error);
|
||||
});
|
||||
}, function (error) {
|
||||
core.setFailed(error);
|
||||
});
|
||||
}
|
||||
else {
|
||||
yield installer_1.default(hugoVersion);
|
||||
yield dump();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ const get_url_1 = __importDefault(require("./get-url"));
|
|||
function installer(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const extended = core.getInput("extended");
|
||||
const extended = core.getInput('extended');
|
||||
console.log(`Hugo extended: ${extended}`);
|
||||
const osName = get_os_1.default(process.platform);
|
||||
console.log(`Operating System: ${osName}`);
|
||||
|
|
@ -38,13 +38,13 @@ function installer(version) {
|
|||
core.addPath(hugoPath);
|
||||
// Download and extract Hugo binary
|
||||
const hugoAssets = yield tc.downloadTool(hugoURL);
|
||||
let hugoBin = "";
|
||||
if (osName === "Windows") {
|
||||
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, "/tmp");
|
||||
let hugoBin = '';
|
||||
if (osName === 'Windows') {
|
||||
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, '/tmp');
|
||||
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
|
||||
}
|
||||
else {
|
||||
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, "/tmp");
|
||||
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, '/tmp');
|
||||
hugoBin = `${hugoExtractedFolder}/hugo`;
|
||||
}
|
||||
yield io.mv(hugoBin, hugoPath);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue