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

outdated-depth-deep.js « tap « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d4a6428a0dbbae4dfc38bafc578b924024b01f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
var common = require("../common-tap")
  , path = require("path")
  , test = require("tap").test
  , rimraf = require("rimraf")
  , npm = require("../../")
  , mr = require("npm-registry-mock")
  , pkg = path.resolve(__dirname, "outdated-depth-deep")
  , cache = path.resolve(pkg, "cache")

var osenv = require("osenv")
var mkdirp = require("mkdirp")
var fs = require("fs")

var pj = JSON.stringify({
  "name": "whatever",
  "description": "yeah idk",
  "version": "1.2.3",
  "main": "index.js",
  "dependencies": {
    "underscore": "1.3.1",
    "npm-test-peer-deps": "0.0.0"
  },
  "repository": "git://github.com/luk-/whatever"
}, null, 2)

function cleanup () {
  process.chdir(osenv.tmpdir())
  rimraf.sync(pkg)
}

function setup () {
  mkdirp.sync(pkg)
  process.chdir(pkg)
  fs.writeFileSync(path.resolve(pkg, "package.json"), pj)
}

test("setup", function (t) {
  cleanup()
  setup()
  t.end()
})

test("outdated depth deep (9999)", function (t) {
  var underscoreOutdated = ["underscore", "1.3.1", "1.3.1", "1.5.1", "1.3.1"]
  var childPkg = path.resolve(pkg, "node_modules", "npm-test-peer-deps")

  var expected = [ [childPkg].concat(underscoreOutdated).concat([null]),
                   [pkg].concat(underscoreOutdated).concat([null]) ]

  process.chdir(pkg)

  mr({port : common.port}, function (er, s) {
    npm.load({
      cache: cache
    , loglevel: "silent"
    , registry: common.registry
    , depth: 9999
    }
    , function () {
        npm.install(".", function (er) {
          if (er) throw new Error(er)
          npm.explore("npm-test-peer-deps", "npm", "install", "underscore", function (er) {
            if (er) throw new Error(er)
            npm.outdated(function (err, d) {
              if (err) throw new Error(err)
              t.deepEqual(d, expected)
              s.close()
              t.end()
            })
          })
        })
      }
    )
  })
})


test("cleanup", function (t) {
  cleanup()
  t.end()
})