tsbuild/ts/tsbuild.cli.ts

49 lines
1.6 KiB
TypeScript
Raw Normal View History

2024-05-10 13:55:25 +00:00
import * as plugins from './plugins.js';
import * as paths from './paths.js';
2022-03-12 18:05:46 +00:00
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._;
2024-05-10 13:55:25 +00:00
listedDirectories.shift(); // removes the first element that is "custom"
2020-04-30 09:02:43 +00:00
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
2024-05-10 13:55:25 +00:00
/**
* the custom command compiles any customDir to dist_customDir
*/
tsbuildCli.addCommand('tsfolders').subscribe(async (argvArg) => {
const tsFolders = await plugins.smartfile.fs.listFolders(paths.cwd, /^ts/)
const compilationCommandObject: { [key: string]: string } = {};
for (const tsFolder of tsFolders) {
compilationCommandObject[`./${tsFolder}/**/*.ts`] = `./dist_${tsFolder}`;
}
await tsbuild.compileGlobStringObject(compilationCommandObject, {}, process.cwd(), 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();
};