initial commit

This commit is contained in:
Justin McCormick
2022-08-15 05:43:24 -04:00
commit a28ec64800
8 changed files with 4077 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import core from "@actions/core";
import Converter from "ansi-to-html";
import fs from "fs";
const converter = new Converter();
const input = core.getInput("input", { required: false });
const encoding = core.getInput("encoding", {
required: true,
});
const path = core.getInput("path", { required: false });
if (!input && !path) {
core.setFailed("You must provide either an input or path.");
}
if (input && path) {
core.setFailed("You must provide either an input or path, not both.");
}
if (input && input !== "") {
core.setOutput("contents", converter.toHtml(input));
} else if (path && path !== "") {
const rawContents = fs.readFileSync(path).toString(encoding);
core.setOutput("contents", converter.toHtml(rawContents));
}