read-package-json
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "read-package-json", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"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", |
@@ -79,18 +79,22 @@ // vim: set softtabstop=16 shiftwidth=16: | ||
fs.readFile(file, "utf8", function (er, d) { | ||
if (er && er.code === "ENOENT") { | ||
indexjs(file, er, cb) | ||
return | ||
} | ||
if (er) return cb(er); | ||
try { | ||
d = JSON.parse(d) | ||
} catch (er) { | ||
er = parseError(er, file); | ||
return cb(er); | ||
} | ||
extras(file, d, cb) | ||
parseJson(file, er, d, cb) | ||
}) | ||
} | ||
function parseJson (file, er, d, cb) { | ||
if (er && er.code === "ENOENT") { | ||
indexjs(file, er, cb) | ||
return | ||
} | ||
if (er) return cb(er); | ||
try { | ||
d = JSON.parse(d) | ||
} catch (er) { | ||
d = parseIndex(d) | ||
if (!d) return cb(parseError(er, file)); | ||
} | ||
extras(file, d, cb) | ||
} | ||
function indexjs (file, er, cb) { | ||
@@ -230,3 +234,3 @@ if (path.basename(file) === "index.js") { | ||
if (er) return cb(er); | ||
if (!files.length) return cb() | ||
if (!files.length) return cb(); | ||
var rm = path.resolve(dir, files[0]) | ||
@@ -334,4 +338,2 @@ readme_(file, data, rm, cb) | ||
function typoWarn (file, data) { | ||
if (typoWarned[data._id]) return; | ||
typoWarned[data._id] = true | ||
if (data.modules) { | ||
@@ -348,2 +350,3 @@ warn(file, data, | ||
noreadmeWarn(file, data) | ||
typoWarned[data._id] = true | ||
} | ||
@@ -492,2 +495,3 @@ | ||
function warn (f, d, m) { | ||
if (typoWarned[d._id]) return; | ||
readJson.log.warn("package.json", d._id, m) | ||
@@ -494,0 +498,0 @@ } |
@@ -0,1 +1,2 @@ | ||
// vim: set softtabstop=16 shiftwidth=16: | ||
var tap = require("tap") | ||
@@ -2,0 +3,0 @@ var readJson = require("../") |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
30557
6
642
3