diff options
author | isaacs <i@izs.me> | 2011-01-09 10:57:11 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2011-01-09 10:57:11 +0300 |
commit | 2aa9747b4795fc216b06a86450ecdd736534fe68 (patch) | |
tree | 357ab4b4da41f398df6de1703c3ac51b52344db5 /bin/read-package-json.js | |
parent | 1424fb379939625dd03ce15ca617fbb8244e5564 (diff) |
Use the package.json data in the installation
So to verify the version of node in use. Note that this install.sh
can't be deployed until AFTER this node is published.
Diffstat (limited to 'bin/read-package-json.js')
-rw-r--r-- | bin/read-package-json.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/read-package-json.js b/bin/read-package-json.js new file mode 100644 index 000000000..84944df72 --- /dev/null +++ b/bin/read-package-json.js @@ -0,0 +1,18 @@ +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] + , data = JSON.parse(fs.readFileSync(file, "utf8")) + +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) +}) |