Skip to content

Commit

Permalink
[Fix] sync/async: pass a dir into maybeUnwrapSymlink
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Nov 22, 2019
1 parent ecd0672 commit 4f2f504
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ module.exports = function resolve(x, options, callback) {
}
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null);

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

maybeUnwrapSymlink(path.join(x, 'package.json'), opts, function (unwrapErr, pkgfile) {
maybeUnwrapSymlink(x, opts, function (unwrapErr, pkgdir) {
if (unwrapErr) return cb(unwrapErr);
var pkgfile = path.join(pkgdir, 'package.json');
isFile(pkgfile, function (err, ex) {
if (err) return cb(err);
if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);
Expand Down
4 changes: 2 additions & 2 deletions lib/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module.exports = function (x, options) {
}
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;

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

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

function loadAsDirectorySync(x) {
var pkgfile = maybeUnwrapSymlink(path.join(x, '/package.json'), opts);
var pkgfile = path.join(maybeUnwrapSymlink(x, opts), '/package.json');
if (isFile(pkgfile)) {
try {
var body = readFileSync(pkgfile, 'UTF8');
Expand Down

0 comments on commit 4f2f504

Please sign in to comment.