Skip to content

Conversation

pksunkara
Copy link
Contributor

Fixes the following issue:


🚀  Invoking generator for vue-cli-plugin-storybook...
 ERROR  TypeError: Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
    at resolveDeps (/home/circleci/vue-cli-plugin-storybook/node_modules/@vue/cli/lib/util/mergeDeps.js:14:27)
    at GeneratorAPI.extendPackage (/home/circleci/vue-cli-plugin-storybook/node_modules/@vue/cli/lib/GeneratorAPI.js:195:20)
    at module.exports (/home/circleci/vue-cli-plugin-storybook/tmp/node_modules/vue-cli-plugin-storybook/generator/index.js:9:7)
    at Generator.initPlugins (/home/circleci/vue-cli-plugin-storybook/node_modules/@vue/cli/lib/Generator.js:150:13)
    at Generator.generate (/home/circleci/vue-cli-plugin-storybook/node_modules/@vue/cli/lib/Generator.js:168:16)
    at runGenerator (/home/circleci/vue-cli-plugin-storybook/node_modules/@vue/cli/lib/invoke.js:124:19)
    at process._tickCallback (internal/process/next_tick.js:68:7)


What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

@pksunkara pksunkara requested a review from haoqunjiang January 6, 2020 07:03
@haoqunjiang
Copy link
Member

In which case it would be a non-string and why should we accept non-string value?

@pksunkara
Copy link
Contributor Author

We should kick it up to the package manager. Right now, this is crashing unexpectedly.

@haoqunjiang
Copy link
Member

Makes sense. Please add a test here:

test('api: warn invalid dep range', async () => {

@pksunkara
Copy link
Contributor Author

Updated. Before the fix, the test will fail as shown below:

 FAIL  packages/@vue/cli/__tests__/Generator.spec.js
  ● api: warn invalid dep range when non-string

    TypeError: Cannot read property 'match' of null

      13 |     const r2IsString = typeof r2 === 'string'
      14 |     const sourceGeneratorId = sources[name]
    > 15 |     const isValidURI = r2.match(/^(?:file|git|git\+ssh|git\+http|git\+https|git\+file|https?):/) != null
         |                           ^
      16 |     const isValidGitHub = r2IsString && r2.match(/^[^/]+\/[^/]+/) != null
      17 | 
      18 |     // if they are the same, do nothing. Helps when non semver type deps are used

      at mergeDeps (packages/@vue/cli/lib/util/mergeDeps.js:15:27)
      at GeneratorAPI.extendPackage (packages/@vue/cli/lib/GeneratorAPI.js:195:20)
      at apply (packages/@vue/cli/__tests__/Generator.spec.js:288:13)
      at Generator.initPlugins (packages/@vue/cli/lib/Generator.js:150:13)
      at Generator.generate (packages/@vue/cli/lib/Generator.js:168:16)
      at Object.<anonymous> (packages/@vue/cli/__tests__/Generator.spec.js:297:19)

Now, the test will pass.

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

Successfully merging this pull request may close these issues.

2 participants