tsdoc/ts/tsdoc.cli.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-06-07 15:54:00 +00:00
import * as plugins from './tsdoc.plugins.js';
import * as paths from './tsdoc.paths.js';
import { logger } from './tsdoc.logging.js';
2019-05-13 17:41:02 +00:00
2022-06-07 15:54:00 +00:00
import { TypeDoc } from './tsdoc.classes.typedoc.js';
2019-05-14 15:39:33 +00:00
2019-05-13 17:41:02 +00:00
export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli();
2022-09-16 06:22:57 +00:00
tsdocCli.standardCommand().subscribe(async (argvArg) => {
2019-05-14 06:50:50 +00:00
logger.log('warn', `Auto detecting environment!`);
2019-05-14 15:39:33 +00:00
switch (true) {
case await TypeDoc.isTypeDocDir(paths.cwd):
logger.log('ok', `Detected TypeDoc compliant directory at ${paths.cwd}`);
2022-09-16 06:22:57 +00:00
tsdocCli.triggerCommand('typedoc', argvArg);
2019-05-14 15:39:33 +00:00
break;
default:
logger.log('error', `Cannot determine docs format at ${paths.cwd}`);
}
2019-05-14 06:50:50 +00:00
});
2019-05-13 17:41:02 +00:00
2020-11-24 20:24:30 +00:00
tsdocCli.addCommand('typedoc').subscribe(async (argvArg) => {
const typeDocInstance = new TypeDoc(paths.cwd);
2020-11-27 12:02:57 +00:00
await typeDocInstance.compile({
2021-03-06 19:21:13 +00:00
publicSubdir: argvArg.publicSubdir,
2020-11-27 12:02:57 +00:00
});
2020-11-24 20:24:30 +00:00
});
tsdocCli.addCommand('test').subscribe((argvArg) => {
2022-09-16 06:22:57 +00:00
tsdocCli.triggerCommand('typedoc', argvArg);
2019-05-27 14:11:10 +00:00
process.on('exit', async () => {
await plugins.smartfile.fs.remove(paths.publicDir);
});
});
2019-05-14 06:50:50 +00:00
tsdocCli.startParse();
};