1 if (process.platform === "win32") {
2 console.log("ok - symlinks are weird on windows, skip this test")
5 var common = require("../common-tap.js")
6 var test = require("tap").test
7 var path = require("path")
9 var rimraf = require("rimraf")
10 var mkdirp = require("mkdirp")
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")
19 var pkgj = { "name":"pkg", "version": "1.2.3"
20 , "dependencies": { "dep": "1.2.3" } }
21 var depj = { "name": "dep", "version": "1.2.3" }
23 var myreg = require("http").createServer(function (q, s) {
25 s.end(JSON.stringify({"error":"forbidden"}) + "\n")
26 }).listen(common.port)
28 test("setup", function (t) {
31 mkdirp.sync(path.resolve(pkg, "node_modules"))
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")
41 test("ignore install if package is linked", function (t) {
42 common.npm(["install"], {
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"
53 }, function (er, code) {
55 t.equal(code, 0, "npm install exited with code")
60 test("still a symlink", function (t) {
61 t.equal(true, fs.lstatSync(target).isSymbolicLink())
65 test("cleanup", function (t) {