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

Add an option to return real paths for symlinks #142

Closed
bajtos opened this issue Nov 29, 2014 · 4 comments
Closed

Add an option to return real paths for symlinks #142

bajtos opened this issue Nov 29, 2014 · 4 comments

Comments

@bajtos
Copy link

bajtos commented Nov 29, 2014

Node Inspector is using glob to find all javascript files that may be loaded later by node in order to allow developers to set breakpoints in files before they are loaded. This is useful e.g. when debugging unit-tests via node --debug-brk, as the test files are loaded later by the test runner.

At the moment, this mechanism does not work for symlinked files (typically via npm link {module}), because glob returns paths in project's node_modules folder, while node resolves all symlinks to real paths before passing the filename to V8.

I am proposing to add a glob option to tell it to convert symlinks to real paths. While this can be implemented by Node Inspector as a post-processing step calling fs.realpath on all items returned by glob, it seems to me that we can get better performance by implementing this feature in glob, as it is already fs API.

Example

File layout:

~/my-module
~/my-module/node_modules
~/my-module/node_modules/debug -> /usr/local/lib/node_modules/debug
~/my-module/index.js
/usr/local/lib/node_modules/debug
/usr/local/lib/node_modules/debug/debug.js
/usr/local/lib/node_modules/debug/node.js

Expected result for glob('**/*.js', { cwd: '~/my-module', realpaths: true }):

~/my-module/index.js
/usr/local/lib/node_modules/debug/debug.js
/usr/local/lib/node_modules/debug/node.js
@bajtos
Copy link
Author

bajtos commented Nov 29, 2014

Related: #139

@isaacs
Copy link
Owner

isaacs commented Nov 29, 2014

Patch welcome. Make sure to add tests for both sync and async behavior. The option should be realpath:true (to better match stat:true behavior).

@isaacs
Copy link
Owner

isaacs commented Nov 29, 2014

Make sure to take advantage of the cache option to fs.realpath, so that it can avoid statting the same paths multiple times.

@bajtos
Copy link
Author

bajtos commented Dec 1, 2014

Thanks. I don't have time to work on this right now, but perhaps one of Node Inspector users will be willing to contribute the patch.

wesleycho added a commit to wesleycho/node-glob that referenced this issue Dec 20, 2014
This adds support for following symlinks with * and ** patterns.

Fixes isaacs#142
wesleycho added a commit to wesleycho/node-glob that referenced this issue Dec 20, 2014
This adds support for following symlinks with * and ** patterns.

Fixes isaacs#142

Fix option name to preferred name, add sync version test
wesleycho added a commit to wesleycho/node-glob that referenced this issue Dec 20, 2014
This adds support for following symlinks with * and ** patterns.

Fixes isaacs#142

Fix option name to preferred name, add sync version test

Fix sync test with actual test, fix old prop name
wesleycho added a commit to wesleycho/node-glob that referenced this issue Dec 20, 2014
This adds support for following symlinks with * and ** patterns.

Fixes isaacs#142

Fix option name to preferred name, add sync version test

Fix sync test with actual test, fix old prop name

Fix tests, split off to new file
@isaacs isaacs closed this as completed in ba29ec3 Mar 6, 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 a pull request may close this issue.

2 participants