Add "targets" command

This commit is contained in:
K35
2022-01-07 08:45:08 +00:00
parent 49425cab39
commit 983ba1f870
4 changed files with 20 additions and 8 deletions

View File

@ -2,7 +2,7 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import startCompile, { Target } from "./process";
import startCompile, { Target, Targets } from "./process";
import dbg from "debug";
const log = dbg("app");
@ -54,6 +54,12 @@ yargs(hideBin(process.argv))
})
}
)
.command("targets", "List all targets", (yargs)=>yargs, ()=>{
console.log("Targets:")
Targets.forEach((__dirname, target) => {
console.log(" " + target);
})
})
.option("verbose", {
alias: "v",
type: "boolean",

View File

@ -16,12 +16,13 @@ class CatchedError extends Error {}
const log = dbg("app");
const Targets = new Map<string, typeof CompileTarget>();
export const Targets = new Map<string, typeof CompileTarget>();
Targets.set("ts-esm", ESMTypescriptTarget);
Targets.set("ts-node", NodeJSTypescriptTarget);
Targets.set("c#", CSharpTarget as typeof CompileTarget);
function indexToLineAndCol(src: string, index: number) {
let line = 1;
let col = 1;