Files
Trez.One 463e2b5545
Release Bundled Action / release (push) Successful in 1m51s
Renovate / renovate (push) Successful in 5m46s
Re-doing bundling...
2025-11-19 13:51:13 -05:00

35 lines
927 B
JavaScript

import Converter from "ansi-to-html";
import * as core from "@actions/core";
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 path = core.getInput("path", { required: false });
if (!input && !path) {
return core.setFailed("You must provide either an input or path.");
}
if (input && path) {
return core.setFailed("You must provide either an input or path, not both.");
}
if (input) {
core.setOutput("contents", converter.toHtml(input));
} else {
if (!fs.existsSync(path)) {
return core.setFailed(`Path ${path} does not exist.`);
}
const raw = fs.readFileSync(path).toString(encoding);
core.setOutput("contents", converter.toHtml(raw));
}
}
try {
main();
} catch (err) {
core.setFailed(err.message);
}