tsbuild/ts/tsbuild.cli.ts

47 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-03-12 18:05:46 +00:00
import * as plugins from './tsbuild.plugins.js';
import * as tsbuild from './tsbuild.exports.js';
2020-04-30 09:02:43 +00:00
export const runCli = async () => {
const tsbuildCli = new plugins.smartcli.Smartcli();
2020-04-30 09:02:43 +00:00
/**
* the standard task compiles anything in ts/ directory to dist directory
*/
2022-08-03 17:34:51 +00:00
tsbuildCli.standardCommand().subscribe(async (argvArg) => {
tsbuild.compileGlobStringObject(
{
2020-04-30 09:02:43 +00:00
'./ts/**/*.ts': './dist_ts',
},
{},
process.cwd(),
argvArg
);
2020-04-30 09:02:43 +00:00
});
2018-12-05 22:32:27 +00:00
2020-04-30 09:02:43 +00:00
/**
* the custom command compiles any customDir to dist_customDir
*/
tsbuildCli.addCommand('custom').subscribe(async (argvArg) => {
const listedDirectories = argvArg._;
listedDirectories.shift();
const compilationCommandObject: { [key: string]: string } = {};
for (const directory of listedDirectories) {
compilationCommandObject[`./${directory}/**/*.ts`] = `./dist_${directory}`;
}
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), argvArg);
});
2020-03-09 15:14:06 +00:00
2020-04-30 09:02:43 +00:00
tsbuildCli.addCommand('element').subscribe(async (argvArg) => {
await tsbuild.compileGlobStringObject(
{
'./ts_web/**/*.ts': 'dist_ts_web',
},
{},
process.cwd(),
2022-03-18 13:32:35 +00:00
{ web: true, ...argvArg }
2020-04-30 09:02:43 +00:00
);
});
2019-01-27 01:42:58 +00:00
2020-04-30 09:02:43 +00:00
tsbuildCli.startParse();
};