tsdoc/ts/tsdoc.cli.ts

44 lines
1.4 KiB
TypeScript
Raw Permalink 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';
import { MkDocs } from './tsdoc.classes.mkdocs';
2019-05-13 17:41:02 +00:00
export const run = async () => {
const tsdocCli = new plugins.smartcli.Smartcli();
2019-05-14 15:39:33 +00:00
tsdocCli.addCommand('typedoc').subscribe(async argvArg => {
2019-05-15 19:23:45 +00:00
const typeDocInstance = new TypeDoc(paths.cwd);
await typeDocInstance.compile();
2019-05-14 15:39:33 +00:00
});
2019-05-13 17:41:02 +00:00
2019-05-15 19:23:45 +00:00
tsdocCli.addCommand('mkdocs').subscribe(async argvArg => {
await MkDocs.handleCommand(argvArg);
});
2019-05-13 17:41:02 +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;
case await MkDocs.isMkDocsDir(paths.cwd):
2019-05-15 19:23:45 +00:00
logger.log('ok', `Detected MkDocs compliant directory at ${paths.cwd}`);
tsdocCli.trigger('mkdocs');
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
2019-05-27 14:11:10 +00:00
tsdocCli.addCommand('test').subscribe(argvArg => {
tsdocCli.trigger('typedoc');
process.on('exit', async () => {
await plugins.smartfile.fs.remove(paths.publicDir);
});
});
2019-05-14 06:50:50 +00:00
tsdocCli.startParse();
};