Skip to content
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

fix(generator): allow passing builder to getGenerator #9574

Merged
merged 3 commits into from Aug 12, 2021
Merged

fix(generator): allow passing builder to getGenerator #9574

merged 3 commits into from Aug 12, 2021

Conversation

mrazauskas
Copy link

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

It seems like constructor of Generator class has to receive two arguments (nuxt and builder). Currently getGenerate helper is passing only nuxt to the class. Therefor calling getGenerate(nuxt) throws 'TypeError: Cannot read property 'forGenerate' of undefined...'. It originates from this line, because this.builder is undefined.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

getGenerate is rather minor and obvious function. I can’t spot it in the test suite. Hope it is acceptable to keep it untested.

@codecov-commenter
Copy link

Codecov Report

Merging #9574 (e677bed) into dev (8e725d3) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #9574      +/-   ##
==========================================
- Coverage   65.15%   65.14%   -0.02%     
==========================================
  Files          94       94              
  Lines        4107     4108       +1     
  Branches     1126     1126              
==========================================
  Hits         2676     2676              
- Misses       1152     1153       +1     
  Partials      279      279              
Flag Coverage Δ
unittests 65.14% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/generator/src/index.js 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e725d3...e677bed. Read the comment docs.

@mrazauskas mrazauskas changed the title fix: make getGenerator pass builder to Generator fix: make getGenerator pass builder argument to the Generator class Jul 20, 2021
@pi0
Copy link
Member

pi0 commented Aug 11, 2021

Thanks for notice and PR @mrazauskas. To avoid cycling dependency between generator and builder, what do you think if:

  • Allow passing second builder argument to getGenerator
  • Check this.builder here and either skip if or throw an error that it is required when build flag is set.

@pi0 pi0 mentioned this pull request Aug 11, 2021
@pi0 pi0 changed the title fix: make getGenerator pass builder argument to the Generator class fix(generator): allow passing builder to getGenerator Aug 11, 2021
@mrazauskas
Copy link
Author

mrazauskas commented Aug 12, 2021

@pi0 Thanks for the review.

Fixed it. getGenerator now is slim and has similar API as Generator class. That’s better solution, right?

The error message is added as separate PR. See #9663.

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 merged commit 1b66e9c into nuxt:dev Aug 12, 2021
@mrazauskas mrazauskas deleted the fix-pass-builder-to-Generator branch August 12, 2021 10:42
@danielroe danielroe added the 2.x label Jan 18, 2023
@danielroe danielroe mentioned this pull request Jan 19, 2023
@danielroe danielroe mentioned this pull request Feb 1, 2023
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 this pull request may close these issues.

None yet

4 participants