refactor: enhance error handling
This commit is contained in:
parent
2eb9c97d23
commit
f9f7965bdf
2 changed files with 45 additions and 68 deletions
68
node_modules/@actions/exec/package.json
generated
vendored
68
node_modules/@actions/exec/package.json
generated
vendored
|
|
@ -1,39 +1,15 @@
|
||||||
{
|
{
|
||||||
"_from": "@actions/exec",
|
"name": "@actions/exec",
|
||||||
"_id": "@actions/exec@1.0.1",
|
"version": "1.0.1",
|
||||||
"_inBundle": false,
|
|
||||||
"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==",
|
|
||||||
"_location": "/@actions/exec",
|
|
||||||
"_phantomChildren": {},
|
|
||||||
"_requested": {
|
|
||||||
"type": "tag",
|
|
||||||
"registry": true,
|
|
||||||
"raw": "@actions/exec",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"escapedName": "@actions%2fexec",
|
|
||||||
"scope": "@actions",
|
|
||||||
"rawSpec": "",
|
|
||||||
"saveSpec": null,
|
|
||||||
"fetchSpec": "latest"
|
|
||||||
},
|
|
||||||
"_requiredBy": [
|
|
||||||
"#USER",
|
|
||||||
"/",
|
|
||||||
"/@actions/tool-cache"
|
|
||||||
],
|
|
||||||
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz",
|
|
||||||
"_shasum": "1624b541165697e7008d7c87bc1f69f191263c6c",
|
|
||||||
"_spec": "@actions/exec",
|
|
||||||
"_where": "/Users/iris/Documents/repos/github.com/peaceiris/actions-hugo",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/actions/toolkit/issues"
|
|
||||||
},
|
|
||||||
"bundleDependencies": false,
|
|
||||||
"deprecated": false,
|
|
||||||
"description": "Actions exec lib",
|
"description": "Actions exec lib",
|
||||||
"devDependencies": {
|
"keywords": [
|
||||||
"@actions/io": "^1.0.1"
|
"github",
|
||||||
},
|
"actions",
|
||||||
|
"exec"
|
||||||
|
],
|
||||||
|
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "lib/exec.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
|
|
@ -41,16 +17,6 @@
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
|
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
|
||||||
"keywords": [
|
|
||||||
"github",
|
|
||||||
"actions",
|
|
||||||
"exec"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"main": "lib/exec.js",
|
|
||||||
"name": "@actions/exec",
|
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
|
@ -62,5 +28,15 @@
|
||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"version": "1.0.1"
|
"bugs": {
|
||||||
}
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
},
|
||||||
|
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz"
|
||||||
|
,"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ=="
|
||||||
|
,"_from": "@actions/exec@1.0.1"
|
||||||
|
}
|
||||||
45
src/index.ts
45
src/index.ts
|
|
@ -5,30 +5,31 @@ import installer from "./installer";
|
||||||
|
|
||||||
// most @actions toolkit packages have async methods
|
// most @actions toolkit packages have async methods
|
||||||
async function run() {
|
async function run() {
|
||||||
|
const dump = async () => {
|
||||||
|
// Show version
|
||||||
|
await exec.exec("hugo version");
|
||||||
|
await exec.exec("go version");
|
||||||
|
await exec.exec("git --version");
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getLatestVersion().then(
|
const hugoVersion: string = core.getInput("hugo-version");
|
||||||
async function(latestVersion): Promise<void> {
|
console.log(`Hugo version: ${hugoVersion}`);
|
||||||
const hugoVersion: string = core.getInput("hugo-version");
|
|
||||||
console.log(`Hugo version: ${hugoVersion}`);
|
|
||||||
const version = (v: string, latestVersion: string): string => {
|
|
||||||
if (v === "" || v === "latest") {
|
|
||||||
return latestVersion;
|
|
||||||
} else {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
await installer(version(hugoVersion, latestVersion));
|
if (hugoVersion === "" || hugoVersion === "latest") {
|
||||||
|
getLatestVersion().then(
|
||||||
// Show version
|
async function(latestVersion): Promise<void> {
|
||||||
await exec.exec("hugo version");
|
await installer(latestVersion);
|
||||||
await exec.exec("go version");
|
await dump();
|
||||||
await exec.exec("git --version");
|
},
|
||||||
},
|
function(error) {
|
||||||
function(error) {
|
core.setFailed(error);
|
||||||
core.setFailed(error);
|
}
|
||||||
}
|
);
|
||||||
);
|
} else {
|
||||||
|
await installer(hugoVersion);
|
||||||
|
await dump();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue