diff --git a/package.json b/package.json index 9971ab1..6f5d74d 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "scripts": { "test": "tsrun test/test.ts", + "testCustom": "node cli.ts.js custom ts_web", "build": "node cli.ts.js" }, "repository": { diff --git a/ts/tsbuild.cli.ts b/ts/tsbuild.cli.ts index db79a74..9c53342 100644 --- a/ts/tsbuild.cli.ts +++ b/ts/tsbuild.cli.ts @@ -3,6 +3,9 @@ import * as tsbuild from './tsbuild.exports'; const tsbuildCli = new plugins.smartcli.Smartcli(); +/** + * the standard task compiles anything in ts/ directory to dist directory + */ tsbuildCli.standardTask().subscribe(argvArg => { if (process.env.CLI_CALL_TSBUILD === 'true') { tsbuild.compileGlobStringObject( @@ -16,4 +19,22 @@ tsbuildCli.standardTask().subscribe(argvArg => { } }); +/** + * the custom command compiles any customDir to dist_customDir + */ +tsbuildCli.addCommand('custom').subscribe(argvArg => { + const listedDirectories = argvArg._; + listedDirectories.shift(); + const compilationCommandObject: {[key: string]: string} = {}; + for (const directory of listedDirectories) { + compilationCommandObject['./' + directory] = './dist_' + directory; + }; + tsbuild.compileGlobStringObject( + compilationCommandObject, + {}, + process.cwd(), + argvArg + ); +}) + tsbuildCli.startParse();