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

Find all node_modules directories, not only nearest to root #442

Merged
merged 1 commit into from
Dec 27, 2013

Conversation

floatdrop
Copy link
Contributor

Findup searches for the first node_modules directory in cwd and
it's ancestors, but what if our generators in ~/node_modules,
and we calling generator in directory, that has node_modules?
Right - yo will think, that you have 0 generators.

Closes #440

nodeModules.forEach(function (root) {
if (!root) return;
var found = glob.sync('generator-*', { cwd: root, stat: true })
.map(function( match ) {
Copy link
Member

Choose a reason for hiding this comment

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

wrong style guide 👅

@SBoudrias
Copy link
Member

This will require some unit test.

Also to make sure the generators are registered in the good older. Nearet node_modules/ must be registered in priority.

if (!root) return;
var found = glob.sync('generator-*', { cwd: root, stat: true })
.map(function( match ) {
.forEach(function (root) {
Copy link
Member

Choose a reason for hiding this comment

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

no need for a line return before the forEach block.

@SBoudrias
Copy link
Member

I'm not sure about the way you refactored this. There's now two describe block with #lookup.

What I meant earlier was:

describe #lookup
  before (etc)
  it (basic assertions)
  describe 'when there's ancestor node_modules/ folder'
    it (assertions related to nested node_modules)

@floatdrop
Copy link
Contributor Author

Done. This line seems strange for me, because it is not clear, why concatenate in reverse order, but it does the needed behaviour - store registers nearest generator at last, so other generators (that are in ancestors) won't override it.


describe('when there\'s ancestor node_modules/ folder', function() {
Copy link
Member

Choose a reason for hiding this comment

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

space after function keyword

@SBoudrias
Copy link
Member

I think we should also add a test to make sure local modules are prioritize over global modules. Mind taking care of this one as you're already on it?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) when pulling ba3b055 on floatdrop:findup-all-issue-440 into e7cf9f8 on yeoman:master.

@@ -20,6 +20,7 @@ describe('Environment Resolver', function () {
shell.exec('npm install', { silent: true });
shell.exec('npm install generator-jquery', { silent: true });
shell.exec('npm install -g generator-angular', { silent: true });
shell.exec('npm install -g generator-dummy', { silent: true });
Copy link
Member

Choose a reason for hiding this comment

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

you can put both on the same line so we only spawn a single process: npm install -g generator-angular generator-dummy

Findup searches for the first `node_modules` directory in cwd and
it's ancestors, but what if our generators in `~/node_modules`,
and we calling generator in directory, that has `node_modules`?
Right - `yo` will think, that you have 0 generators.

Closes yeoman#440
@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) when pulling eca985a on floatdrop:findup-all-issue-440 into e7cf9f8 on yeoman:master.

@floatdrop
Copy link
Contributor Author

Merged npm installs.

@SBoudrias SBoudrias merged commit eca985a into yeoman:master Dec 27, 2013
@SBoudrias
Copy link
Member

Thank you a lot for this one! Good work, keep them coming.

@floatdrop
Copy link
Contributor Author

Thanks for advices and code-review @SBoudrias ! I hope next time my code will be clearer. 😊

P.s. this pr will allow generator-github to push directory to github (even if there is node_modules inside).

@floatdrop floatdrop deleted the findup-all-issue-440 branch December 27, 2013 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_getNpmGenerators should look in all node_modules
3 participants