import { Command, option } from 'commander' import creatDebugger from 'debug' import { tsc } from './commands/tsc' import { CliArgs } from './interfaces' const program = new Command() const dConfig = creatDebugger('config') const dCommon = creatDebugger('common') function main() { if (process.argv.length === 2) { dCommon('command: tsc') tsc().then(() => { process.exit(0) }) } program .version('0.0.0', '-v, --version') .option('-w, --watch', 'Watch input files.') .option( '-p, --project', `FILE OR DIRECTORY, --project FILE OR DIRECTORY Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.` ) program.parse() const options = program.opts() dConfig(`command args: %O`, options) const cliArgs: CliArgs = {} if (options.watch) cliArgs.watch = true if (options.project) cliArgs.project = options.project tsc({ cliArgs, }) } main()