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

Environment.prototype.resolveModulePath() resolves only directories if no file extension specified. #33

Merged
merged 1 commit into from
Apr 2, 2015

Conversation

Freyert
Copy link
Contributor

@Freyert Freyert commented Mar 29, 2015

This solves an issue where package.json would be resolved instead of package/index.js. It forces all module resolutions to directories. Fix suggested by @SBoudrias.

@@ -400,7 +400,7 @@ Environment.prototype.resolveModulePath = function resolveModulePath(moduleId) {
moduleId = path.resolve(moduleId);
}

return require.resolve(untildify(moduleId));
return require.resolve(untildify(moduleId) + path.sep);
Copy link
Member

Choose a reason for hiding this comment

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

Should we make sure the file path we get here is not pointing to a file before adding a separator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I was thinking about that as I was walking around today. require.resolve will only resolve to a .js file or a .json file? Also, aren't all generators meant to be scoped by directory?

Copy link
Member

Choose a reason for hiding this comment

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

require.resolve will only resolve to a .js file or a .json file?

Yes

Also, aren't all generators meant to be scoped by directory?

Yes, but we can't assume this method is always receiving a folder. It'd make it pretty brittle

@sindresorhus
Copy link
Member

Please use a descriptive title for the PR and commit.

@Freyert Freyert closed this Apr 1, 2015
@Freyert Freyert reopened this Apr 1, 2015
@Freyert Freyert closed this Apr 1, 2015
@Freyert Freyert reopened this Apr 1, 2015
@Freyert Freyert changed the title Closes yeoman/generator#779 Environment.prototype.resolveModulePath resolves only directories if no file extension specified. Apr 1, 2015
@Freyert Freyert changed the title Environment.prototype.resolveModulePath resolves only directories if no file extension specified. Environment.prototype.resolveModulePath() resolves only directories if no file extension specified. Apr 1, 2015
@Freyert
Copy link
Contributor Author

Freyert commented Apr 1, 2015

Sorry for flipping it open and close so many times. Still trying to figure out a lot of GitHub stuff. I think the new revisions are good. Let me know if I the PR title or commit is too verbose.

@SBoudrias
Copy link
Member

LGTM, thanks for taking care of this!

@SBoudrias
Copy link
Member

One of your test is failing though, check Travis log for the details.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 91.82% when pulling 8a94cae on Freyert:master into d4036a5 on yeoman:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 91.82% when pulling 8a94cae on Freyert:master into d4036a5 on yeoman:master.

@Freyert
Copy link
Contributor Author

Freyert commented Apr 2, 2015

Yay I did it! Thanks for the patience.

@SBoudrias
Copy link
Member

Awesome thanks!

SBoudrias added a commit that referenced this pull request Apr 2, 2015
Environment.prototype.resolveModulePath() resolves only directories if no file extension specified.
@SBoudrias SBoudrias merged commit c12276e into yeoman:master Apr 2, 2015
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.

None yet

4 participants