diff options
author | isaacs <i@izs.me> | 2011-04-30 21:55:01 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-04-30 22:00:00 +0400 |
commit | 1287c7fd4481c921881a39ed27fee7965e3b241a (patch) | |
tree | 0c41fae6c9fdf33e2aeedcab3da87f89bc7b0084 /bin | |
parent | 29d3d59f124467276e0637ca281222aec39e1bec (diff) |
Read contributors out of AUTHORS file, if present
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/read-package-json.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/read-package-json.js b/bin/read-package-json.js index 84944df72..8c95d86e8 100755 --- a/bin/read-package-json.js +++ b/bin/read-package-json.js @@ -3,16 +3,20 @@ if (argv.length < 3) { console.error("Usage: read-package.json <file> [<fields> ...]") process.exit(1) } + var fs = require("fs") , file = argv[2] - , data = JSON.parse(fs.readFileSync(file, "utf8")) + , readJson = require("../lib/utils/read-json") -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] +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) }) - console.log(val) }) |