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
|
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 = path.resolve(__dirname, "shrinkwrap-empty-deps")
, cache = path.resolve(pkg, "cache")
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: cache, registry: common.registry}, function () {
cb()
})
}
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(path.resolve(pkg, "npm-shrinkwrap.json"))
}
|