[Pkg-javascript-commits] [node-module-deps] 162/444: bubble up 2 more error cases

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:47:52 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 0e9639f58332612b09f174f115e64ffdf38b19a3
Author: James Halliday <mail at substack.net>
Date:   Wed Jan 29 05:40:27 2014 -0800

    bubble up 2 more error cases
---
 index.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index 10c1927..ea33b6f 100644
--- a/index.js
+++ b/index.js
@@ -50,6 +50,7 @@ module.exports = function (mains, opts) {
             if (pkgCache[id]) return done();
             
             lookupPkg(main, function (err, pkg) {
+                if (err) return output.emit('error', err);
                 if (!pkg) pkg = {};
                 if (!pkg.__dirname) pkg.__dirname = path.dirname(id);
                 pkgCache[id] = pkg;
@@ -125,6 +126,7 @@ module.exports = function (mains, opts) {
             if (pkg && pkgdir) pkg.__dirname = pkgdir;
             if (!pkg || !pkg.__dirname) {
                 lookupPkg(file, function (err, p) {
+                    if (err) return output.emit('error', err);
                     if (!p) p = {};
                     if (!p.__dirname) p.__dirname = path.dirname(file);
                     pkgCache[file] = p;
@@ -311,7 +313,11 @@ function lookupPkg (file, cb) {
         fs.readFile(pkgfile, function (err, src) {
             if (err) return next();
             try { var pkg = JSON.parse(src) }
-            catch (err) { return cb(err) }
+            catch (err) {
+                return cb(new Error([
+                    err + ' while parsing json file ' + pkgfile
+                ].join('')))
+            }
             pkg.__dirname = dir;
             cb(null, pkg);
         });

-- 
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