diff --git a/packages/taro-cli/src/create/project.ts b/packages/taro-cli/src/create/project.ts index 7b892494a17a..362cdba5355a 100644 --- a/packages/taro-cli/src/create/project.ts +++ b/packages/taro-cli/src/create/project.ts @@ -43,6 +43,7 @@ export interface IProjectConf { hideDefaultTemplate?: boolean framework: FrameworkType compiler?: CompilerType + ask?: (config: object) => Promise | void } type CustomPartial = Omit & Partial>; @@ -126,6 +127,16 @@ export default class Project extends Creator { await this.askTemplate(conf, prompts, templates) const templateChoiceAnswer = await inquirer.prompt(prompts) + // 导航步骤扩展 + try { + if (typeof conf.ask === 'function') { + const { ask, ...other } = conf + await ask({ ...other, templatePath: this.templatePath(templateChoiceAnswer.template) }) + } + } catch (e) { + console.error(e) + } + return { ...answers, ...compilerAndTemplateSourceAnswer, diff --git a/packages/taro-cli/src/presets/commands/init.ts b/packages/taro-cli/src/presets/commands/init.ts index 9e9f520537ce..cffbaf99af28 100644 --- a/packages/taro-cli/src/presets/commands/init.ts +++ b/packages/taro-cli/src/presets/commands/init.ts @@ -34,6 +34,7 @@ export default (ctx: IPluginContext) => { hideDefaultTemplate, sourceRoot, autoInstall, + ask } = opts.options const Project = require('../../create/project').default @@ -52,7 +53,8 @@ export default (ctx: IPluginContext) => { compiler, hideDefaultTemplate, autoInstall, - css + css, + ask }) project.create()