Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0f9056dcb | |||
| 463e2b5545 | |||
| 9a7015553a | |||
| 8987d79032 |
@@ -5,9 +5,7 @@ import fs from "fs";
|
||||
export function main() {
|
||||
const converter = new Converter();
|
||||
const input = core.getInput("input", { required: false });
|
||||
const encoding = core.getInput("encoding", {
|
||||
required: true,
|
||||
});
|
||||
const encoding = core.getInput("encoding", { required: true });
|
||||
const path = core.getInput("path", { required: false });
|
||||
|
||||
if (!input && !path) {
|
||||
@@ -15,20 +13,23 @@ export function main() {
|
||||
}
|
||||
|
||||
if (input && path) {
|
||||
return core.setFailed(
|
||||
"You must provide either an input or path, not both."
|
||||
);
|
||||
return core.setFailed("You must provide either an input or path, not both.");
|
||||
}
|
||||
|
||||
if (input && input !== "") {
|
||||
if (input) {
|
||||
core.setOutput("contents", converter.toHtml(input));
|
||||
} else if (path && path !== "") {
|
||||
} else {
|
||||
if (!fs.existsSync(path)) {
|
||||
return core.setFailed(`Path ${path} does not exist.`);
|
||||
}
|
||||
|
||||
const rawContents = fs.readFileSync(path).toString(encoding);
|
||||
|
||||
core.setOutput("contents", converter.toHtml(rawContents));
|
||||
const raw = fs.readFileSync(path).toString(encoding);
|
||||
core.setOutput("contents", converter.toHtml(raw));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
main();
|
||||
} catch (err) {
|
||||
core.setFailed(err.message);
|
||||
}
|
||||
+1
-1
@@ -20,4 +20,4 @@ outputs:
|
||||
description: "The input or contents of path where all ANSI codes have been replaced with HTML color codes."
|
||||
runs:
|
||||
using: "node16"
|
||||
main: "./index.js"
|
||||
main: "dist/index.js"
|
||||
|
||||
Vendored
+11
-11
@@ -3762,9 +3762,7 @@ var __webpack_exports__ = {};
|
||||
function main() {
|
||||
const converter = new ansi_to_html__WEBPACK_IMPORTED_MODULE_0__();
|
||||
const input = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("input", { required: false });
|
||||
const encoding = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("encoding", {
|
||||
required: true,
|
||||
});
|
||||
const encoding = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("encoding", { required: true });
|
||||
const path = _actions_core__WEBPACK_IMPORTED_MODULE_1__.getInput("path", { required: false });
|
||||
|
||||
if (!input && !path) {
|
||||
@@ -3772,24 +3770,26 @@ function main() {
|
||||
}
|
||||
|
||||
if (input && path) {
|
||||
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(
|
||||
"You must provide either an input or path, not both."
|
||||
);
|
||||
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed("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));
|
||||
} else if (path && path !== "") {
|
||||
} else {
|
||||
if (!fs__WEBPACK_IMPORTED_MODULE_2__.existsSync(path)) {
|
||||
return _actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(`Path ${path} does not exist.`);
|
||||
}
|
||||
|
||||
const rawContents = fs__WEBPACK_IMPORTED_MODULE_2__.readFileSync(path).toString(encoding);
|
||||
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput("contents", converter.toHtml(rawContents));
|
||||
const raw = fs__WEBPACK_IMPORTED_MODULE_2__.readFileSync(path).toString(encoding);
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setOutput("contents", converter.toHtml(raw));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
main();
|
||||
} catch (err) {
|
||||
_actions_core__WEBPACK_IMPORTED_MODULE_1__.setFailed(err.message);
|
||||
}
|
||||
})();
|
||||
|
||||
var __webpack_exports__main = __webpack_exports__.D;
|
||||
|
||||
Generated
+27
-8
@@ -3028,11 +3028,14 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.7.23",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz",
|
||||
"integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==",
|
||||
"version": "18.19.130",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz",
|
||||
"integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/normalize-package-data": {
|
||||
"version": "2.4.1",
|
||||
@@ -11562,6 +11565,13 @@
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
|
||||
@@ -14175,10 +14185,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "18.7.23",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz",
|
||||
"integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==",
|
||||
"dev": true
|
||||
"version": "18.19.130",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz",
|
||||
"integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
},
|
||||
"@types/normalize-package-data": {
|
||||
"version": "2.4.1",
|
||||
@@ -20404,6 +20417,12 @@
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"undici-types": {
|
||||
"version": "5.26.5",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
|
||||
"dev": true
|
||||
},
|
||||
"unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz",
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@
|
||||
"scripts": {
|
||||
"lint": "eslint --ext js .",
|
||||
"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": {
|
||||
"@actions/core": "^1.9.1",
|
||||
|
||||
Reference in New Issue
Block a user