diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 4f07b4da..e0991d70 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -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): typeof cmd => { +const wrapCommand = (cmd: (...args: any[]) => Promise): typeof cmd => { const wrappedCommand: typeof cmd = (...args) => cmd(...args).catch((err) => { error(err.stack); diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 07cde5e3..4445e326 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -7,7 +7,7 @@ import { UserConfig } from '../types'; import { loadUserConfig } from '../utils/loadUserConfig'; export const scripts = (defaultAppConfig: UserConfig) => { - const entry = async (): Promise => { + const entry = async (): Promise => { 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;