|
| 1 | +var common = require("../common-tap") |
| 2 | + , path = require("path") |
| 3 | + , test = require("tap").test |
| 4 | + , rimraf = require("rimraf") |
| 5 | + , npm = require("../../") |
| 6 | + , mr = require("npm-registry-mock") |
| 7 | + , pkg = path.resolve(__dirname, "outdated-depth-deep") |
| 8 | + , cache = path.resolve(pkg, "cache") |
| 9 | + |
| 10 | +var osenv = require("osenv") |
| 11 | +var mkdirp = require("mkdirp") |
| 12 | +var fs = require("fs") |
| 13 | + |
| 14 | +var pj = JSON.stringify({ |
| 15 | + "name": "whatever", |
| 16 | + "description": "yeah idk", |
| 17 | + "version": "1.2.3", |
| 18 | + "main": "index.js", |
| 19 | + "dependencies": { |
| 20 | + "underscore": "1.3.1", |
| 21 | + "npm-test-peer-deps": "0.0.0" |
| 22 | + }, |
| 23 | + "repository": "git://github.com/luk-/whatever" |
| 24 | +}, null, 2) |
| 25 | + |
| 26 | +function cleanup () { |
| 27 | + process.chdir(osenv.tmpdir()) |
| 28 | + rimraf.sync(pkg) |
| 29 | +} |
| 30 | + |
| 31 | +function setup () { |
| 32 | + mkdirp.sync(pkg) |
| 33 | + process.chdir(pkg) |
| 34 | + fs.writeFileSync(path.resolve(pkg, "package.json"), pj) |
| 35 | +} |
| 36 | + |
| 37 | +test("setup", function (t) { |
| 38 | + cleanup() |
| 39 | + setup() |
| 40 | + t.end() |
| 41 | +}) |
| 42 | + |
| 43 | +test("outdated depth deep (9999)", function (t) { |
| 44 | + var underscoreOutdated = ["underscore", "1.3.1", "1.3.1", "1.5.1", "1.3.1"] |
| 45 | + var childPkg = path.resolve(pkg, "node_modules", "npm-test-peer-deps") |
| 46 | + |
| 47 | + var expected = [ [pkg].concat(underscoreOutdated), |
| 48 | + [childPkg].concat(underscoreOutdated) ] |
| 49 | + |
| 50 | + process.chdir(pkg) |
| 51 | + |
| 52 | + mr({port : common.port}, function (er, s) { |
| 53 | + npm.load({ |
| 54 | + cache: cache |
| 55 | + , loglevel: "silent" |
| 56 | + , registry: common.registry |
| 57 | + , depth: 9999 |
| 58 | + } |
| 59 | + , function () { |
| 60 | + npm.install(".", function (er) { |
| 61 | + if (er) throw new Error(er) |
| 62 | + npm.outdated(function (err, d) { |
| 63 | + if (err) throw new Error(err) |
| 64 | + t.deepEqual(d, expected) |
| 65 | + s.close() |
| 66 | + t.end() |
| 67 | + }) |
| 68 | + }) |
| 69 | + } |
| 70 | + ) |
| 71 | + }) |
| 72 | +}) |
| 73 | + |
| 74 | + |
| 75 | +test("cleanup", function (t) { |
| 76 | + cleanup() |
| 77 | + t.end() |
| 78 | +}) |
0 commit comments