read-package-json
Advanced tools
Comparing version 2.0.3 to 2.0.4
{ | ||
"name": "read-package-json", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)", | ||
@@ -5,0 +5,0 @@ "description": "The thing npm uses to read package.json files with semantics and defaults and validation", |
@@ -61,3 +61,14 @@ var fs | ||
function parseJson (file, er, d, log, strict, cb) { | ||
if (er && er.code === 'ENOENT') return indexjs(file, er, log, strict, cb) | ||
if (er && er.code === 'ENOENT') { | ||
return fs.stat(path.dirname(file), function (err, stat) { | ||
if (!err && stat && !stat.isDirectory()) { | ||
// ENOTDIR isn't used on Windows, but npm expects it. | ||
er = Object.create(er) | ||
er.code = 'ENOTDIR' | ||
return cb(er) | ||
} else { | ||
return indexjs(file, er, log, strict, cb) | ||
} | ||
}) | ||
} | ||
if (er) return cb(er) | ||
@@ -64,0 +75,0 @@ |
@@ -13,1 +13,9 @@ var tap = require('tap') | ||
}) | ||
tap.test('ENOTDIR for non-directory packages', function (t) { | ||
readJson(path.resolve(__filename, 'package.json'), function (er, data) { | ||
t.ok(er) | ||
t.equal(er.code, 'ENOTDIR') | ||
t.end() | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
629
23807
24