refactor: enhance error message of promise reject
This commit is contained in:
parent
ab1914bc1a
commit
947ed8e60f
3 changed files with 7 additions and 7 deletions
6
.github/workflows/test.yml
vendored
6
.github/workflows/test.yml
vendored
|
|
@ -27,8 +27,10 @@ jobs:
|
|||
needs: test
|
||||
strategy:
|
||||
matrix:
|
||||
hugo-version: ['latest', '0.58.2']
|
||||
extended: [true, false]
|
||||
hugo-version: ['latest']
|
||||
extended: [true]
|
||||
# hugo-version: ['latest', '0.58.2']
|
||||
# extended: [true, false]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
|
|
|||
|
|
@ -6,14 +6,13 @@ function getLatestVersion() {
|
|||
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) {
|
||||
const result = JSON.parse(xhr.responseText);
|
||||
const latestVersion = result.versions.stable;
|
||||
resolve(latestVersion);
|
||||
} else if (xhr.readyState === 4 && xhr.status !== 200) {
|
||||
reject(`ERROR: got status ${xhr.status}`);
|
||||
reject(`ERROR: got status ${xhr.status} of ${url}`);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
|||
5
index.js
5
index.js
|
|
@ -14,9 +14,8 @@ async function run() {
|
|||
}
|
||||
console.log(`Hugo version: ${hugoVersion}`);
|
||||
|
||||
let extended = core.getInput("extended");
|
||||
const extended = core.getInput("extended");
|
||||
console.log(`Hugo extended: ${extended}`);
|
||||
|
||||
let extendedStr = "";
|
||||
if (extended === "true") {
|
||||
extendedStr = "extended_";
|
||||
|
|
@ -41,7 +40,7 @@ async function run() {
|
|||
await io.mv(`${hugoExtractedFolder}/hugo`, hugoPath);
|
||||
},
|
||||
function(error) {
|
||||
console.error(error);
|
||||
core.setFailed(error);
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue