[Pkg-javascript-commits] [node-module-deps] 152/444: recursively load the initial package.json, fails the tr_rel test
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 555d51c9ae69bae339a104d9ec76798dee743e3e
Author: James Halliday <mail at substack.net>
Date: Fri Jan 3 19:21:35 2014 -0800
recursively load the initial package.json, fails the tr_rel test
---
index.js | 21 +++++++++++++--------
package.json | 3 ++-
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/index.js b/index.js
index e8e379e..475ed88 100644
--- a/index.js
+++ b/index.js
@@ -7,6 +7,7 @@ var nodeResolve = require('resolve');
var detective = require('detective');
var through = require('through');
var concat = require('concat-stream');
+var parents = require('parents');
module.exports = function (mains, opts) {
if (!opts) opts = {};
@@ -48,14 +49,18 @@ module.exports = function (mains, opts) {
var id = path.resolve(basedir, main);
if (pkgCache[id]) return done();
- var pkgfile = path.join(path.dirname(main), 'package.json');
- fs.readFile(pkgfile, function (err, src) {
- if (err) return done();
- try { var pkg = JSON.parse(src) }
- catch (err) { return done() }
- pkgCache[id] = pkg;
- done();
- });
+ var dirs = parents(path.dirname(main));
+ (function next () {
+ if (dirs.length === 0) return done();
+ var pkgfile = path.join(dirs.shift(), 'package.json');
+ fs.readFile(pkgfile, function (err, src) {
+ if (err) return next();
+ try { var pkg = JSON.parse(src) }
+ catch (err) { return done() }
+ pkgCache[id] = pkg;
+ done();
+ });
+ })();
});
function done () { if (--pkgCount === 0) next() }
})();
diff --git a/package.json b/package.json
index 2dfe4f3..050ede5 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,8 @@
"resolve": "~0.6.0",
"detective": "~2.1.2",
"concat-stream": "~1.3.1",
- "minimist": "~0.0.5"
+ "minimist": "~0.0.5",
+ "parents": "0.0.2"
},
"devDependencies": {
"tape": "~2.3.2",
--
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