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 bad module resolution (#42) #43

Merged
merged 4 commits into from
Jul 28, 2018
Merged

Conversation

VeselovAlex
Copy link
Contributor

Replace require.resolve('packagename'), which looks for packages relative to markdownlint-cli root, with require.resolve('packagename', {paths}), where paths are calculated relative to working directory

@VeselovAlex
Copy link
Contributor Author

Why does is fail on AppVeyor? Looks like it does not copy package from test\custom-rules\relative-to-cwd\node_modules

@DavidAnson
Copy link
Collaborator

AppVeyor uses Windows, if that is not what you use, maybe there is a path issue there?

Regarding the _ APIs, aren’t those undocumented and unsupported? That worries me, as does the Node 8 requirement. I would love if we could figure out a way to get the right behavior on Node 6 with public APIs.

@VeselovAlex
Copy link
Contributor Author

Node 8 is not required. require.resolve.paths and require.resolve(module, paths) are added to public API in Node 8, so we can use them to search packages relative to working directory. For Node 6 we can use Module._resolveFilename(filepath, {paths: paths}) as a fallback.

To replace Module._nodeModulePaths(process.cwd()) we can create custom function to build node resolution path list, but should we? This method is available even in 0.10.25 and was not modified for at least 2 years, so it seems to be stable enough

@DavidAnson
Copy link
Collaborator

That’s fair, thank you. I’ll have a look at this soon for a new release. I do want to understand the CI failure, though.

@VeselovAlex
Copy link
Contributor Author

Tests fixed, seems to an issue with execa on Windows

@DavidAnson
Copy link
Collaborator

Yay!!

(Did you mean to leave that console.log in the code?)

@DavidAnson
Copy link
Collaborator

I should be able to accept this PR tonight. I’ll also update the markdownlint dependency and investigate the other open issue. Once done, I’ll publish a new version. Thanks for the help!

@DavidAnson DavidAnson merged commit e9392b8 into igorshubovych:master Jul 28, 2018
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.

2 participants