diff --git a/src/tsc-silent.ts b/src/tsc-silent.ts index 3dafbef..5c373d0 100644 --- a/src/tsc-silent.ts +++ b/src/tsc-silent.ts @@ -13,6 +13,7 @@ const argv: Argv = require("yargs") .array("suppress").default("suppress", []) .string("compiler").default("compiler", "node_modules/typescript/lib/typescript.js") .string("project").alias("project", "p") + .string("createSourceFile") .boolean("watch").default("watch", false).alias("watch", "w") .boolean("stats").default("stats", false) .boolean("help") @@ -71,6 +72,11 @@ const formatHost: ts.FormatDiagnosticsHost = { getNewLine: () => ts.sys.newLine }; +if (argv.createSourceFile) { + const originalCreateSourceFile = ts.createSourceFile; + ts.createSourceFile = require(`${process.cwd()}/${argv.createSourceFile}`)(originalCreateSourceFile); +} + if (argv.watch) { let watchDiagnostics: ts.Diagnostic[] = []; const createProgram = ts.createSemanticDiagnosticsBuilderProgram; @@ -253,20 +259,24 @@ function printUsage() { console.log(" [--watch]"); console.log(); console.log("Synopsis:"); - console.log(" --project, -p Path to tsconfig.json"); + console.log(" --project, -p Path to tsconfig.json"); + console.log(); + console.log(" --compiler Path to typescript.js."); + console.log(" By default, uses `./node_modules/typescript/lib/typescript.js`."); console.log(); - console.log(" --compiler Path to typescript.js."); - console.log(" By default, uses `./node_modules/typescript/lib/typescript.js`."); + console.log(" --suppress Suppressed erros."); + console.log(" E.g. `--suppress 7017@src/js/ 2322,2339,2344@/src/legacy/`.") console.log(); - console.log(" --suppress Suppressed erros."); - console.log(" E.g. `--suppress 7017@src/js/ 2322,2339,2344@/src/legacy/`.") + console.log(" --suppressConfig Path to supressed errors config."); + console.log(" See documentation for examples."); console.log(); - console.log(" --suppressConfig Path to supressed errors config."); - console.log(" See documentation for examples."); + console.log(" --watch, -w Run in watch mode."); console.log(); - console.log(" --watch, -w Run in watch mode."); + console.log(" --stats Print number of suppressed errors per path and error code."); console.log(); - console.log(" --stats Print number of suppressed errors per path and error code."); + console.log(". --createSourceFile Custom module to use in place of the default TypeScript logic, + console.log(" it expects a module that exports a single function, with the"); + console.log(" original TypeScript function as sole argument."); console.log(); console.log("Description:"); console.log("The purpose of the wrapper is to execute TypeScript compiler but suppress some error messages");