Welcome to mirror list, hosted at ThFree Co, Russian Federation.

read-package-json.js « bin - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3e5a0c77f254b461f41b7530dda755fc454cca55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)
  })
})