mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(cli): cli返回app
This commit is contained in:
parent
62038c8c60
commit
c41af9d01d
@ -3,12 +3,13 @@ import { cac } from 'cac';
|
||||
import { allowTs } from './utils/allowTs';
|
||||
import { error } from './utils/logger';
|
||||
import { scripts } from './commands';
|
||||
import App from './Core';
|
||||
import { UserConfig } from './types';
|
||||
|
||||
/**
|
||||
* Wrap raw command to catch errors and exit process
|
||||
*/
|
||||
const wrapCommand = (cmd: (...args: any[]) => Promise<void>): typeof cmd => {
|
||||
const wrapCommand = (cmd: (...args: any[]) => Promise<App>): typeof cmd => {
|
||||
const wrappedCommand: typeof cmd = (...args) =>
|
||||
cmd(...args).catch((err) => {
|
||||
error(err.stack);
|
||||
|
@ -7,7 +7,7 @@ import { UserConfig } from '../types';
|
||||
import { loadUserConfig } from '../utils/loadUserConfig';
|
||||
|
||||
export const scripts = (defaultAppConfig: UserConfig) => {
|
||||
const entry = async (): Promise<void> => {
|
||||
const entry = async (): Promise<App> => {
|
||||
if (process.env.NODE_ENV === undefined) {
|
||||
process.env.NODE_ENV = 'development';
|
||||
}
|
||||
@ -34,10 +34,6 @@ export const scripts = (defaultAppConfig: UserConfig) => {
|
||||
},
|
||||
};
|
||||
|
||||
if (appConfig === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// create vuepress app
|
||||
const app = new App(appConfig);
|
||||
|
||||
@ -49,6 +45,8 @@ export const scripts = (defaultAppConfig: UserConfig) => {
|
||||
// initialize and prepare
|
||||
await app.init();
|
||||
await app.prepare();
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
return entry;
|
||||
|
Loading…
x
Reference in New Issue
Block a user