Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore non-object package.json files, fixes #134 #142

Merged
merged 1 commit into from
Feb 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ Deps.prototype.lookupPackage = function (file, cb) {
fns.forEach(function (f) { f(err, pkg) });
}
if (err) cb(err)
else if (pkg) cb(null, pkg)
else if (pkg && typeof pkg === 'object') cb(null, pkg)
else {
self.pkgCache[pkgfile] = false;
next();
Expand Down
16 changes: 16 additions & 0 deletions test/invalid_pkg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var mdeps = require('../');
var test = require('tap').test;
var path = require('path');
var fs = require('fs');

test('invalid pkg', function (t) {
var d = mdeps();
d.on('package', function (pkg_) {
// console.error({pkg_});
});
d.end(path.join(__dirname, '/invalid_pkg/file.js'));
d.on('data', function () {});
d.on('end', function () {
t.end();
});
});
1 change: 1 addition & 0 deletions test/invalid_pkg/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('./')
1 change: 1 addition & 0 deletions test/invalid_pkg/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
T.pass()
1 change: 1 addition & 0 deletions test/invalid_pkg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"just a string"