This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Supports npm outdated include package type with long option
- Loading branch information
Showing
2 changed files
with
119 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
var path = require("path") | ||
|
||
var mr = require("npm-registry-mock") | ||
var rimraf = require("rimraf") | ||
var test = require("tap").test | ||
|
||
var common = require("../common-tap.js") | ||
var npm = require("../../") | ||
|
||
// config | ||
var pkg = path.resolve(__dirname, "outdated") | ||
var cache = path.resolve(pkg, "cache") | ||
var nodeModules = path.resolve(pkg, "node_modules") | ||
|
||
test("it should not throw", function (t) { | ||
cleanup() | ||
process.chdir(pkg) | ||
|
||
var originalLog = console.log | ||
var output = [] | ||
var expOut = [ path.resolve(__dirname, "outdated/node_modules/underscore"), | ||
path.resolve(__dirname, "outdated/node_modules/underscore") | ||
+ ":[email protected]" | ||
+ ":[email protected]" | ||
+ ":[email protected]" | ||
+ ":dependencies" ] | ||
var expData = [ [ path.resolve(__dirname, "outdated"), | ||
"underscore", | ||
"1.3.1", | ||
"1.3.1", | ||
"1.5.1", | ||
"1.3.1", | ||
"dependencies" ] ] | ||
|
||
console.log = function () { | ||
output.push.apply(output, arguments) | ||
} | ||
mr(common.port, function (s) { | ||
npm.load({ | ||
cache : "cache", | ||
loglevel : "silent", | ||
parseable : true, | ||
registry : common.registry | ||
}, | ||
function () { | ||
npm.install(".", function (err) { | ||
t.ifError(err, "install success") | ||
npm.config.set("long", true) | ||
npm.outdated(function (er, d) { | ||
t.ifError(er, "outdated success") | ||
console.log = originalLog | ||
t.same(output, expOut) | ||
t.same(d, expData) | ||
s.close() | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
test("cleanup", function (t) { | ||
cleanup() | ||
t.end() | ||
}) | ||
|
||
function cleanup () { | ||
rimraf.sync(nodeModules) | ||
rimraf.sync(cache) | ||
} |