node/deps/npm/test/packages/npm-test-peer-deps/test.js

37 lines
881 B
JavaScript
Raw Normal View History

2013-01-10 07:21:30 +08:00
var path = require("path")
var assert = require("assert")
process.env.npm_config_prefix = process.cwd()
delete process.env.npm_config_global
delete process.env.npm_config_depth
var npm = process.env.npm_execpath
2013-02-07 00:39:27 +08:00
require("child_process").execFile(process.execPath, [npm, "ls", "--json"], {
2013-01-10 07:21:30 +08:00
env: process.env, cwd: process.cwd() },
function (err, stdout, stderr) {
if (err) throw err
var actual = JSON.parse(stdout).dependencies
2013-01-19 04:12:07 +08:00
var expected = require("./npm-ls.json")
2013-02-07 00:39:27 +08:00
// resolved url doesn't matter
2013-03-07 07:41:06 +08:00
clean(actual)
clean(expected)
2013-02-07 00:39:27 +08:00
2013-01-19 04:12:07 +08:00
console.error(JSON.stringify(actual, null, 2))
console.error(JSON.stringify(expected, null, 2))
2013-01-10 07:21:30 +08:00
assert.deepEqual(actual, expected)
})
2013-03-07 07:41:06 +08:00
function clean (obj) {
for (var i in obj) {
if (i === "from" || i === "resolved")
delete obj[i]
else if (typeof obj[i] === "object" && obj[i])
clean(obj[i])
}
}