Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 463e2b5545 |
@@ -5,9 +5,7 @@ import fs from "fs";
|
|||||||
export function main() {
|
export function main() {
|
||||||
const converter = new Converter();
|
const converter = new Converter();
|
||||||
const input = core.getInput("input", { required: false });
|
const input = core.getInput("input", { required: false });
|
||||||
const encoding = core.getInput("encoding", {
|
const encoding = core.getInput("encoding", { required: true });
|
||||||
required: true,
|
|
||||||
});
|
|
||||||
const path = core.getInput("path", { required: false });
|
const path = core.getInput("path", { required: false });
|
||||||
|
|
||||||
if (!input && !path) {
|
if (!input && !path) {
|
||||||
@@ -15,20 +13,23 @@ export function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input && path) {
|
if (input && path) {
|
||||||
return core.setFailed(
|
return core.setFailed("You must provide either an input or path, not both.");
|
||||||
"You must provide either an input or path, not both."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input && input !== "") {
|
if (input) {
|
||||||
core.setOutput("contents", converter.toHtml(input));
|
core.setOutput("contents", converter.toHtml(input));
|
||||||
} else if (path && path !== "") {
|
} else {
|
||||||
if (!fs.existsSync(path)) {
|
if (!fs.existsSync(path)) {
|
||||||
return core.setFailed(`Path ${path} does not exist.`);
|
return core.setFailed(`Path ${path} does not exist.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawContents = fs.readFileSync(path).toString(encoding);
|
const raw = fs.readFileSync(path).toString(encoding);
|
||||||
|
core.setOutput("contents", converter.toHtml(raw));
|
||||||
core.setOutput("contents", converter.toHtml(rawContents));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
main();
|
||||||
|
} catch (err) {
|
||||||
|
core.setFailed(err.message);
|
||||||
|
}
|
||||||
Vendored
+11
-11
@@ -3762,9 +3762,7 @@ var __webpack_exports__ = {};
|
|||||||
function main() {
|
function main() {
|
||||||
const converter = new ansi_to_html__WEBPACK_IMPORTED_MODULE_0__();
|
const converter = new ansi_to_html__WEBPACK_IMPORTED_MODULE_0__();
|
||||||
const input = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("input", { required: false });
|
const input = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("input", { required: false });
|
||||||
const encoding = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("encoding", {
|
const encoding = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("encoding", { required: true });
|
||||||
required: true,
|
|
||||||
});
|
|
||||||
const path = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("path", { required: false });
|
const path = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("path", { required: false });
|
||||||
|
|
||||||
if (!input && !path) {
|
if (!input && !path) {
|
||||||
@@ -3772,24 +3770,26 @@ function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (input && path) {
|
if (input && path) {
|
||||||
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(
|
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed("You must provide either an input or path, not both.");
|
||||||
"You must provide either an input or path, not both."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input && input !== "") {
|
if (input) {
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput("contents", converter.toHtml(input));
|
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput("contents", converter.toHtml(input));
|
||||||
} else if (path && path !== "") {
|
} else {
|
||||||
if (!fs__WEBPACK_IMPORTED_MODULE_2__.existsSync(path)) {
|
if (!fs__WEBPACK_IMPORTED_MODULE_2__.existsSync(path)) {
|
||||||
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(`Path ${path} does not exist.`);
|
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(`Path ${path} does not exist.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rawContents = fs__WEBPACK_IMPORTED_MODULE_2__.readFileSync(path).toString(encoding);
|
const raw = fs__WEBPACK_IMPORTED_MODULE_2__.readFileSync(path).toString(encoding);
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput("contents", converter.toHtml(raw));
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput("contents", converter.toHtml(rawContents));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
main();
|
||||||
|
} catch (err) {
|
||||||
|
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(err.message);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var __webpack_exports__main = __webpack_exports__.D;
|
var __webpack_exports__main = __webpack_exports__.D;
|
||||||
|
|||||||
+2
-1
@@ -14,7 +14,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint --ext js .",
|
"lint": "eslint --ext js .",
|
||||||
"release": "npx semantic-release",
|
"release": "npx semantic-release",
|
||||||
"test": "npx cross-env FORCE_COLOR=1 npx jest"
|
"test": "npx cross-env FORCE_COLOR=1 npx jest",
|
||||||
|
"build": "ncc build action.js -o dist"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.9.1",
|
"@actions/core": "^1.9.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user