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

shrinkwrap-empty-deps.js « tap « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9ec8e71e0baf4c380888b9f8da8bdd8bba1debb6 (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
var test = require("tap").test
  , npm = require("../../")
  , mr = require("npm-registry-mock")
  , common = require("../common-tap.js")
  , path = require("path")
  , fs = require("fs")
  , osenv = require("osenv")
  , rimraf = require("rimraf")
  , pkg = __dirname + "/shrinkwrap-empty-deps"

test("returns a list of removed items", function (t) {
  var desiredResultsPath = path.resolve(pkg, "npm-shrinkwrap.json")

  cleanup()

  mr(common.port, function (s) {
    setup(function () {
      npm.shrinkwrap([], function (err) {
        if (err) return t.fail(err)
        fs.readFile(desiredResultsPath, function (err, desired) {
          if (err) return t.fail(err)
          t.deepEqual({
            "name": "npm-test-shrinkwrap-empty-deps",
            "version": "0.0.0",
            "dependencies": {}
          }, JSON.parse(desired))
          cleanup()
          s.close()
          t.end()
        })
      })
    })
  })
})

function setup (cb) {
  cleanup()
  process.chdir(pkg)
  npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
    cb()
  })
}

function cleanup () {
  process.chdir(osenv.tmpdir())
  rimraf.sync(path.resolve(pkg, "npm-shrinkwrap.json"))
}