Skip to content

Commit 4f2f504

Browse files
committed
[Fix] sync/async: pass a dir into maybeUnwrapSymlink
1 parent ecd0672 commit 4f2f504

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/async.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ module.exports = function resolve(x, options, callback) {
171171
}
172172
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null);
173173

174-
maybeUnwrapSymlink(path.join(dir, 'package.json'), opts, function (unwrapErr, pkgfile) {
174+
maybeUnwrapSymlink(dir, opts, function (unwrapErr, pkgdir) {
175175
if (unwrapErr) return loadpkg(path.dirname(dir), cb);
176+
var pkgfile = path.join(pkgdir, 'package.json');
176177
isFile(pkgfile, function (err, ex) {
177178
// on err, ex is false
178179
if (!ex) return loadpkg(path.dirname(dir), cb);
@@ -198,8 +199,9 @@ module.exports = function resolve(x, options, callback) {
198199
fpkg = opts.package;
199200
}
200201

201-
maybeUnwrapSymlink(path.join(x, 'package.json'), opts, function (unwrapErr, pkgfile) {
202+
maybeUnwrapSymlink(x, opts, function (unwrapErr, pkgdir) {
202203
if (unwrapErr) return cb(unwrapErr);
204+
var pkgfile = path.join(pkgdir, 'package.json');
203205
isFile(pkgfile, function (err, ex) {
204206
if (err) return cb(err);
205207
if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);

lib/sync.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ module.exports = function (x, options) {
105105
}
106106
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;
107107

108-
var pkgfile = maybeUnwrapSymlink(path.join(dir, 'package.json'), opts);
108+
var pkgfile = path.join(maybeUnwrapSymlink(dir, opts), 'package.json');
109109

110110
if (!isFile(pkgfile)) {
111111
return loadpkg(path.dirname(dir));
@@ -125,7 +125,7 @@ module.exports = function (x, options) {
125125
}
126126

127127
function loadAsDirectorySync(x) {
128-
var pkgfile = maybeUnwrapSymlink(path.join(x, '/package.json'), opts);
128+
var pkgfile = path.join(maybeUnwrapSymlink(x, opts), '/package.json');
129129
if (isFile(pkgfile)) {
130130
try {
131131
var body = readFileSync(pkgfile, 'UTF8');

0 commit comments

Comments
 (0)