-
Notifications
You must be signed in to change notification settings - Fork 68
Resolve symlinked modules correctly #92
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
Changes from 6 commits
80f49da
3969cb4
dde7bf5
cae50e3
dd08cbf
e6fa508
c0f34a6
75f41c2
77a2650
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,7 +206,7 @@ function build_resolve_opts(opts, base) { | |
| return opts; | ||
| } | ||
|
|
||
| function resolve(id, opts, cb) { | ||
| function resolve(id, opts, callback) { | ||
|
|
||
| // opts.filename | ||
| // opts.paths | ||
|
|
@@ -216,6 +216,20 @@ function resolve(id, opts, cb) { | |
| opts = opts || {}; | ||
| opts.filename = opts.filename || ''; | ||
|
|
||
| var cb = function(err, path, pkg) { | ||
| fs.stat(path, function(notPath) { | ||
| if (notPath) callback(err, path, pkg); | ||
| else { | ||
| fs.realpath(path, function(notReal, real) { | ||
| if (notReal) callback(err, path, pkg); | ||
|
||
| else { | ||
| callback(err, real, pkg); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| var base = path.dirname(opts.filename); | ||
|
|
||
| if (opts.basedir) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,8 @@ | |
| "empty.js" | ||
| ], | ||
| "scripts": { | ||
| "test": "mocha --reporter list test/*.js" | ||
| "test": "mocha --reporter list test/*.js", | ||
| "postinstall": "node scripts/setup-symlinks.js" | ||
|
||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| var fs = require('fs'); | ||
|
|
||
| try { | ||
| fs.mkdirSync(__dirname + '/../test/fixtures/node_modules/linker/node_modules'); | ||
| } catch (e) {} | ||
| process.chdir(__dirname + '/../test/fixtures/node_modules/linker/node_modules'); | ||
| try { | ||
| fs.unlinkSync('linked'); | ||
| } catch (e) {} | ||
| fs.symlinkSync('../../../linked', 'linked', 'dir'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| // dummy |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this set of nested functions trying to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2a) if it's a regular file, resolve to it
2b) if it's a symlink, resolve to its realpath