You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
504 B

var argv = process.argv
if (argv.length < 3) {
console.error("Usage: read-package.json <file> [<fields> ...]")
process.exit(1)
}
var fs = require("fs")
, file = argv[2]
, readJson = require("read-package-json")
readJson(file, function (er, data) {
if (er) throw er
if (argv.length === 3) console.log(data)
else argv.slice(3).forEach(function (field) {
field = field.split(".")
var val = data
field.forEach(function (f) {
val = val[f]
})
console.log(val)
})
})