• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var readInstalled = require("../read-installed.js")
2var json = require("../package.json")
3var d = Object.keys(json.dependencies)
4var dd = Object.keys(json.devDependencies)
5var od = Object.keys(json.optionalDependencies)
6var known = d.concat(dd).concat(od).sort()
7var test = require("tap").test
8var path = require("path")
9
10test("make sure that it works", function (t) {
11  readInstalled(path.join(__dirname, "../"), {
12    dev: true,
13    log: console.error
14  }, function (er, map) {
15    t.notOk(er, "er should be bull")
16    t.ok(map, "map should be data")
17    if (er) return console.error(er.stack || er.message)
18    cleanup(map)
19    var deps = Object.keys(map.dependencies).sort()
20    t.equal(known.length, deps.length, "array lengths are equal")
21    t.deepEqual(known, deps, "arrays should be equal")
22    t.notOk(map.dependencies.tap.extraneous, 'extraneous not set on devDep')
23    t.end()
24  })
25})
26
27var seen = []
28function cleanup (map) {
29  if (seen.indexOf(map) !== -1) return
30  seen.push(map)
31  for (var i in map) switch (i) {
32    case "_id":
33    case "path":
34    case "extraneous": case "invalid":
35    case "dependencies": case "name":
36      continue
37    default: delete map[i]
38  }
39  var dep = map.dependencies
40  if (dep) {
41    for (var i in dep) if (typeof dep[i] === "object") {
42      cleanup(dep[i])
43    }
44  }
45  return map
46}
47