Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/taro-cli/src/create/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface IProjectConf {
hideDefaultTemplate?: boolean
framework: FrameworkType
compiler?: CompilerType
ask?: (config: object) => Promise<void> | void
}

type CustomPartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
Expand Down Expand Up @@ -126,6 +127,16 @@ export default class Project extends Creator {
await this.askTemplate(conf, prompts, templates)
const templateChoiceAnswer = await inquirer.prompt<IProjectConf>(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,
Expand Down
4 changes: 3 additions & 1 deletion packages/taro-cli/src/presets/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default (ctx: IPluginContext) => {
hideDefaultTemplate,
sourceRoot,
autoInstall,
ask
} = opts.options

const Project = require('../../create/project').default
Expand All @@ -52,7 +53,8 @@ export default (ctx: IPluginContext) => {
compiler,
hideDefaultTemplate,
autoInstall,
css
css,
ask
})

project.create()
Expand Down