[Pkg-javascript-commits] [node-module-deps] 155/444: re-lookup when the dirname isn't set

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:51 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-module-deps.

commit c788634a3756f2f91006707ff3e2b646854b665a
Author: James Halliday <mail at substack.net>
Date:   Fri Jan 3 21:40:55 2014 -0800

    re-lookup when the dirname isn't set
---
 index.js | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index 3638f81..f1d90e9 100644
--- a/index.js
+++ b/index.js
@@ -50,7 +50,9 @@ module.exports = function (mains, opts) {
             if (pkgCache[id]) return done();
             
             lookupPkg(main, function (err, pkg) {
-                if (pkg) pkgCache[id] = pkg;
+                if (!pkg) pkg = {};
+                if (!pkg.__dirname) pkg.__dirname = path.dirname(id);
+                pkgCache[id] = pkg;
                 done();
             });
         });
@@ -113,7 +115,7 @@ module.exports = function (mains, opts) {
         if (opts.extensions) parent.extensions = opts.extensions;
         if (opts.modules) parent.modules = opts.modules;
         
-        resolver(id, parent, function (err, file, pkg) {
+        resolver(id, parent, function f (err, file, pkg) {
             if (err) return output.emit('error', err);
             if (!file) return output.emit('error', new Error([
                 'module not found: "' + id + '" from file ',
@@ -122,7 +124,13 @@ module.exports = function (mains, opts) {
             
             if (pkg && pkgdir) pkg.__dirname = pkgdir;
             if (!pkg || !pkg.__dirname) {
-                
+                lookupPkg(file, function (err, p) {
+                    if (!p) p = {};
+                    if (!p.__dirname) p.__dirname = path.dirname(file);
+                    pkgCache[file] = p;
+                    f(err, file, p);
+                });
+                return;
             }
             
             if (cb) cb(file);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-module-deps.git



More information about the Pkg-javascript-commits mailing list