]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/ignore-install-link.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / ignore-install-link.js
1 if (process.platform === "win32") {
2   console.log("ok - symlinks are weird on windows, skip this test")
3   return
4 }
5 var common = require("../common-tap.js")
6 var test = require("tap").test
7 var path = require("path")
8 var fs = require("fs")
9 var rimraf = require("rimraf")
10 var mkdirp = require("mkdirp")
11
12 var root = path.resolve(__dirname, "ignore-install-link")
13 var pkg = path.resolve(root, "pkg")
14 var dep = path.resolve(root, "dep")
15 var target = path.resolve(pkg, "node_modules", "dep")
16 var cache = path.resolve(root, "cache")
17 var globalPath = path.resolve(root, "global")
18
19 var pkgj = { "name":"pkg", "version": "1.2.3"
20            , "dependencies": { "dep": "1.2.3" } }
21 var depj = { "name": "dep", "version": "1.2.3" }
22
23 var myreg = require("http").createServer(function (q, s) {
24   s.statusCode = 403
25   s.end(JSON.stringify({"error":"forbidden"}) + "\n")
26 }).listen(common.port)
27
28 test("setup", function (t) {
29   rimraf.sync(root)
30   mkdirp.sync(root)
31   mkdirp.sync(path.resolve(pkg, "node_modules"))
32   mkdirp.sync(dep)
33   mkdirp.sync(cache)
34   mkdirp.sync(globalPath)
35   fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify(pkgj))
36   fs.writeFileSync(path.resolve(dep, "package.json"), JSON.stringify(depj))
37   fs.symlinkSync(dep, target, "dir")
38   t.end()
39 })
40
41 test("ignore install if package is linked", function (t) {
42   common.npm(["install"], {
43     cwd: pkg,
44     env: {
45       PATH: process.env.PATH || process.env.Path,
46       HOME: process.env.HOME,
47       "npm_config_prefix": globalPath,
48       "npm_config_cache": cache,
49       "npm_config_registry": common.registry,
50       "npm_config_loglevel": "silent"
51     },
52     stdio: "inherit"
53   }, function (er, code) {
54     if (er) throw er
55     t.equal(code, 0, "npm install exited with code")
56     t.end()
57   })
58 })
59
60 test("still a symlink", function (t) {
61   t.equal(true, fs.lstatSync(target).isSymbolicLink())
62   t.end()
63 })
64
65 test("cleanup", function (t) {
66   rimraf.sync(root)
67   myreg.close()
68   t.end()
69 })