]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/outdated-private.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / outdated-private.js
1 var common = require("../common-tap.js")
2 var test = require("tap").test
3 var npm = require("../../")
4 var rimraf = require("rimraf")
5 var path = require("path")
6 var mr = require("npm-registry-mock")
7 var osenv = require("osenv")
8 var mkdirp = require("mkdirp")
9 var fs = require("graceful-fs")
10
11 var pkg = path.resolve(__dirname, "outdated-private")
12 var pkgLocalPrivate = path.resolve(pkg, "local-private")
13 var pkgScopedLocalPrivate = path.resolve(pkg, "another-local-private")
14 var pkgLocalUnderscore = path.resolve(pkg, "underscore")
15
16 var pjParent = JSON.stringify({
17   name         : "outdated-private",
18   version      : "1.0.0",
19   dependencies : {
20     "local-private" : "file:local-private",
21     "@scoped/another-local-private" : "file:another-local-private",
22     "underscore" : "file:underscore"
23   }
24 }, null, 2) + "\n"
25
26 var pjLocalPrivate = JSON.stringify({
27   name         : "local-private",
28   version      : "1.0.0",
29   private      : true
30 }, null, 2) + "\n"
31
32 var pjLocalPrivateBumped = JSON.stringify({
33   name         : "local-private",
34   version      : "1.1.0",
35   private      : true
36 }, null, 2) + "\n"
37
38 var pjScopedLocalPrivate = JSON.stringify({
39   name         : "@scoped/another-local-private",
40   version      : "1.0.0",
41   private      : true
42 }, null, 2) + "\n"
43
44 var pjLocalUnderscore = JSON.stringify({
45   name         : "underscore",
46   version      : "1.3.1"
47 }, null, 2) + "\n"
48
49 test("setup", function (t) {
50   bootstrap()
51   t.end()
52 })
53
54 test("outdated ignores private modules", function (t) {
55   t.plan(3)
56   process.chdir(pkg)
57   mr({ port : common.port }, function (err, s) {
58     npm.load(
59       {
60         loglevel  : "silent",
61         parseable : true,
62         registry  : common.registry
63       },
64       function () {
65         npm.install(".", function (err) {
66           t.ifError(err, "install success")
67           bumpLocalPrivate()
68           npm.outdated(function (er, d) {
69             t.ifError(er, "outdated success")
70             t.deepEqual(d, [[
71               path.resolve(__dirname, "outdated-private"),
72               "underscore",
73               "1.3.1",
74               "1.5.1",
75               "1.5.1",
76               "underscore@1.5.1"
77             ]])
78             s.close()
79           })
80         })
81       }
82     )
83   })
84 })
85
86 test("cleanup", function (t) {
87   cleanup()
88   t.end()
89 })
90
91 function bootstrap () {
92   mkdirp.sync(pkg)
93   fs.writeFileSync(path.resolve(pkg, "package.json"), pjParent)
94
95   mkdirp.sync(pkgLocalPrivate)
96   fs.writeFileSync(path.resolve(pkgLocalPrivate, "package.json"), pjLocalPrivate)
97
98   mkdirp.sync(pkgScopedLocalPrivate)
99   fs.writeFileSync(path.resolve(pkgScopedLocalPrivate, "package.json"), pjScopedLocalPrivate)
100
101   mkdirp.sync(pkgLocalUnderscore)
102   fs.writeFileSync(path.resolve(pkgLocalUnderscore, "package.json"), pjLocalUnderscore)
103 }
104
105 function bumpLocalPrivate () {
106   fs.writeFileSync(path.resolve(pkgLocalPrivate, "package.json"), pjLocalPrivateBumped)
107 }
108
109 function cleanup () {
110   process.chdir(osenv.tmpdir())
111   rimraf.sync(pkg)
112 }