Skip to content

Prompts.js with a function doesn't work when using a plugin in a preset #5124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deraw opened this issue Jan 31, 2020 · 0 comments · Fixed by #5498
Closed

Prompts.js with a function doesn't work when using a plugin in a preset #5124

deraw opened this issue Jan 31, 2020 · 0 comments · Fixed by #5498
Assignees
Labels

Comments

@deraw
Copy link

deraw commented Jan 31, 2020

Version

4.1.2

Environment info

Environment Info:

  System:
    OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 12.13.1 - /usr/local/bin/node
    Yarn: 1.21.1 - /usr/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Browsers:
    Chrome: 79.0.3945.130
    Firefox: 72.0.2
  npmGlobalPackages:
    @vue/cli: 4.1.2

Steps to reproduce

Create a plugin with a prompt.js file that exports a function, eg:

// prompts.js

// pass `package.json` of project to function argument
module.exports = pkg => {
  const prompts = [
    {
      type: 'input',
      name: 'locale',
      message: 'The locale of project localization.',
      validate: input => !!input,
      default: 'en'
    }
  ]

  // add dynamically prompt
  if ('@vue/cli-plugin-eslint' in (pkg.devDependencies || {})) {
    prompts.push({
      type: 'confirm',
      name: 'useESLintPluginVueI18n',
      message: 'Use ESLint plugin for Vue I18n ?'
    })
  }

  return prompts
}

(from the docs https://cli.vuejs.org/dev-guide/plugin-dev.html#prompts)

Use that plugin in a preset and try to create a project using it

What is expected?

The function is called without error

What is actually happening?

This error occurs:

 ERROR  TypeError: obs.pipe is not a function
TypeError: obs.pipe is not a function
    at PromptUI.run (/usr/local/lib/node_modules/@vue/cli/node_modules/inquirer/lib/ui/prompt.js:33:24)
    at Object.promptModule [as prompt] (/usr/local/lib/node_modules/@vue/cli/node_modules/inquirer/lib/inquirer.js:28:22)
    at Creator.resolvePlugins (/usr/local/lib/node_modules/@vue/cli/lib/Creator.js:382:36)
    at Creator.create (/usr/local/lib/node_modules/@vue/cli/lib/Creator.js:196:32)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async create (/usr/local/lib/node_modules/@vue/cli/lib/create.js:72:3)

I think it's because there is no check on prompts type on this line https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/Creator.js#L384

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants