Skip to content

Commit

Permalink
chore: rename outputType to type
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf committed Oct 19, 2023
1 parent c63bcca commit 463f557
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions bin/threatdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ const {
type: "string",
short: "o",
},
outputType: {
type: {
type: "string",
alias: "type",
short: "t",
default: "mermaid",
},
Expand All @@ -40,12 +39,12 @@ async function main () {
const inputFile = positionals.shift();
// non-null assertion safe because the outputType has a default
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (!inputFile || !["json", "mermaid", "svg"].includes(values.outputType!)) {
if (!inputFile || !["json", "mermaid", "svg"].includes(values.type!)) {
usage();
} else {
const fileContent = readFileSync(resolve(process.cwd(), inputFile), { encoding: "utf8" });
const parsedContent = parse(fileContent);
if (values.outputType === "json") {
if (values.type === "json") {
if (values.output) {
writeFileSync(resolve(process.cwd(), values.output), JSON.stringify(parsedContent, null, 2));
} else {
Expand All @@ -55,7 +54,7 @@ async function main () {
}

const mermaidContent = compileToMermaid(parsedContent);
if (values.outputType === "mermaid") {
if (values.type === "mermaid") {
if (values.output) {
writeFileSync(resolve(process.cwd(), values.output), mermaidContent);
} else {
Expand All @@ -65,7 +64,7 @@ async function main () {
}

const svgContent = await renderMermaid(mermaidContent);
if (values.outputType === "svg") {
if (values.type === "svg") {
if (values.output) {
writeFileSync(resolve(process.cwd(), values.output), svgContent);
} else {
Expand Down

0 comments on commit 463f557

Please sign in to comment.