tsdoc/ts/tsdoc.cli.ts

38 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-05-13 17:41:02 +00:00
import * as plugins from './tsdoc.plugins';
2019-05-14 15:39:33 +00:00
import * as paths from './tsdoc.paths';
2019-05-14 06:50:50 +00:00
import { logger } from './tsdoc.logging';
2019-05-13 17:41:02 +00:00
2019-05-14 15:39:33 +00:00
import { TypeDoc } from './tsdoc.classes.typedoc';
2019-05-13 17:41:02 +00:00
export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli();
2020-11-24 20:24:30 +00:00
tsdocCli.standardTask().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}`);
tsdocCli.trigger('typedoc');
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) => {
2019-05-27 14:11:10 +00:00
tsdocCli.trigger('typedoc');
process.on('exit', async () => {
await plugins.smartfile.fs.remove(paths.publicDir);
});
});
2019-05-14 06:50:50 +00:00
tsdocCli.startParse();
};