Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChris Meyers <chris.meyers.fsu@gmail.com>2014-10-01 17:51:22 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-10-04 06:25:59 +0400
commit80557fc773ee9c990bfeb7596830797143c34aee (patch)
tree2233fb3335f74ac822662e6490a5cd16b14dae94 /test
parent8d6bfcb88408f5885a2a67409854c43e5c3a23f6 (diff)
Fixed lint issues.
Diffstat (limited to 'test')
-rw-r--r--test/common-tap.js26
-rw-r--r--test/tap/00-check-mock-dep.js1
-rw-r--r--test/tap/00-verify-bundle-deps.js2
-rw-r--r--test/tap/00-verify-ls-ok.js14
-rw-r--r--test/tap/404-parent.js44
-rw-r--r--test/tap/cache-add-unpublished.js4
-rw-r--r--test/tap/config-meta.js44
-rw-r--r--test/tap/dedupe.js15
-rw-r--r--test/tap/false_name.js15
-rw-r--r--test/tap/git-cache-locking.js12
-rw-r--r--test/tap/global-prefix-set-in-userconfig.js4
-rw-r--r--test/tap/ignore-install-link.js2
-rw-r--r--test/tap/ignore-scripts.js20
-rw-r--r--test/tap/ignore-shrinkwrap.js15
-rw-r--r--test/tap/install-at-locally.js44
-rw-r--r--test/tap/install-cli-production.js44
-rw-r--r--test/tap/install-cli-unicode.js31
-rw-r--r--test/tap/install-from-local.js4
-rw-r--r--test/tap/install-save-exact.js77
-rw-r--r--test/tap/install-save-local.js7
-rw-r--r--test/tap/install-save-prefix.js114
-rw-r--r--test/tap/install-scoped-already-installed.js16
-rw-r--r--test/tap/install-scoped-link.js10
-rw-r--r--test/tap/install-with-dev-dep-duplicate.js2
-rw-r--r--test/tap/invalid-cmd-exit-code.js1
-rw-r--r--test/tap/lifecycle-path.js4
-rw-r--r--test/tap/lifecycle.js6
-rw-r--r--test/tap/login-always-auth.js50
-rw-r--r--test/tap/ls-depth-cli.js48
-rw-r--r--test/tap/ls-depth-unmet.js51
-rw-r--r--test/tap/ls-no-results.js12
-rw-r--r--test/tap/noargs-install-config-save.js16
-rw-r--r--test/tap/npm-api-not-loaded-error.js2
-rw-r--r--test/tap/optional-metadep-rollback-collision.js2
-rw-r--r--test/tap/outdated-color.js22
-rw-r--r--test/tap/outdated-depth.js38
-rw-r--r--test/tap/outdated-git.js21
-rw-r--r--test/tap/outdated-include-devdependencies.js10
-rw-r--r--test/tap/outdated-json.js41
-rw-r--r--test/tap/outdated-new-versions.js10
-rw-r--r--test/tap/outdated.js18
-rw-r--r--test/tap/peer-deps-invalid.js16
-rw-r--r--test/tap/peer-deps-without-package-json.js24
-rw-r--r--test/tap/peer-deps.js2
-rw-r--r--test/tap/prune.js6
-rw-r--r--test/tap/publish-config.js38
-rw-r--r--test/tap/pwd-prefix.js4
-rw-r--r--test/tap/referer.js5
-rw-r--r--test/tap/registry.js18
-rw-r--r--test/tap/run-script.js47
-rw-r--r--test/tap/scripts-whitespace-windows.js60
-rw-r--r--test/tap/semver-doc.js2
-rw-r--r--test/tap/semver-tag.js2
-rw-r--r--test/tap/shrinkwrap-empty-deps.js5
-rw-r--r--test/tap/sorted-package-json.js13
-rw-r--r--test/tap/spawn-enoent.js2
-rw-r--r--test/tap/startstop.js51
-rw-r--r--test/tap/test-run-ls.js6
-rw-r--r--test/tap/uninstall-package.js3
-rw-r--r--test/tap/unpack-foreign-tarball.js42
-rw-r--r--test/tap/update-save.js82
-rw-r--r--test/tap/url-dependencies.js17
-rw-r--r--test/tap/version-no-tags.js80
-rw-r--r--test/tap/view.js22
64 files changed, 747 insertions, 719 deletions
diff --git a/test/common-tap.js b/test/common-tap.js
index 3adeae599..745528944 100644
--- a/test/common-tap.js
+++ b/test/common-tap.js
@@ -1,31 +1,31 @@
var spawn = require("child_process").spawn
var port = exports.port = 1337
-exports.registry = "http://localhost:" + port;
-process.env.npm_config_loglevel = "error";
+exports.registry = "http://localhost:" + port
+process.env.npm_config_loglevel = "error"
-var npm_config_cache = __dirname + '/npm_cache';
+var npm_config_cache = __dirname + '/npm_cache'
exports.child_env = {
npm_config_cache: npm_config_cache,
-};
+}
-var bin = exports.bin = require.resolve("../bin/npm-cli.js");
-var once = require("once");
+var bin = exports.bin = require.resolve("../bin/npm-cli.js")
+var once = require("once")
exports.npm = function (cmd, opts, cb) {
- cb = once(cb);
- cmd = [bin].concat(cmd);
- opts = opts || {};
+ cb = once(cb)
+ cmd = [bin].concat(cmd)
+ opts = opts || {}
- opts.env = opts.env ? opts.env : process.env;
+ opts.env = opts.env ? opts.env : process.env
if (!opts.env.npm_config_cache) {
- opts.env.npm_config_cache = __dirname + "/npm_cache";
+ opts.env.npm_config_cache = __dirname + "/npm_cache"
}
var stdout = ""
, stderr = ""
, node = process.execPath
- , child = spawn(node, cmd, opts);
+ , child = spawn(node, cmd, opts)
if (child.stderr) child.stderr.on("data", function (chunk) {
stderr += chunk
@@ -40,5 +40,5 @@ exports.npm = function (cmd, opts, cb) {
child.on("close", function (code) {
cb(null, code, stdout, stderr)
})
- return child;
+ return child
}
diff --git a/test/tap/00-check-mock-dep.js b/test/tap/00-check-mock-dep.js
index c4d2ff2c2..58932e508 100644
--- a/test/tap/00-check-mock-dep.js
+++ b/test/tap/00-check-mock-dep.js
@@ -1,6 +1,7 @@
console.log("TAP Version 13")
process.on("uncaughtException", function(er) {
+ if (er) { throw er }
console.log("not ok - Failed checking mock registry dep. Expect much fail!")
console.log("1..1")
process.exit(1)
diff --git a/test/tap/00-verify-bundle-deps.js b/test/tap/00-verify-bundle-deps.js
index 00291a6c4..9d16b2d3b 100644
--- a/test/tap/00-verify-bundle-deps.js
+++ b/test/tap/00-verify-bundle-deps.js
@@ -16,7 +16,7 @@ test("all deps are bundled deps or dev deps", function (t) {
})
t.same(
- fs.readdirSync(path.resolve(__dirname, '../../node_modules')).filter(function (name) {
+ fs.readdirSync(path.resolve(__dirname, "../../node_modules")).filter(function (name) {
return (dev.indexOf(name) === -1) && (name !== ".bin")
}).sort(),
bundled.sort(),
diff --git a/test/tap/00-verify-ls-ok.js b/test/tap/00-verify-ls-ok.js
index 8da5f94dd..a1f1ab347 100644
--- a/test/tap/00-verify-ls-ok.js
+++ b/test/tap/00-verify-ls-ok.js
@@ -1,18 +1,18 @@
var common = require("../common-tap")
var test = require("tap").test
-var node = process.execPath
var path = require("path")
var cwd = path.resolve(__dirname, "..", "..")
-var npm = path.resolve(cwd, "cli.js")
-var spawn = require("child_process").spawn
-var fs = require('fs')
+var fs = require("fs")
test("npm ls in npm", function (t) {
- t.ok(fs.existsSync(cwd))
+ t.ok(fs.existsSync(cwd), "ensure that the path we are calling ls within exists")
+ var files = fs.readdirSync(cwd)
+ t.notEqual(files.length, 0, "ensure there are files in the directory we are to ls")
var opt = { cwd: cwd, stdio: [ "ignore", "ignore", 2 ] }
- common.npm(['ls'], opt, function(err, code) {
- t.ok(code > 0)
+ common.npm(["ls"], opt, function(err, code) {
+ t.ifError(err, "error should not exist")
+ t.equal(code, 0, "npm ls exited with code")
t.end()
})
})
diff --git a/test/tap/404-parent.js b/test/tap/404-parent.js
index b3c353827..012beb3de 100644
--- a/test/tap/404-parent.js
+++ b/test/tap/404-parent.js
@@ -1,26 +1,26 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var osenv = require('osenv')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var pkg = path.resolve(__dirname, '404-parent')
+var common = require("../common-tap.js")
+var test = require("tap").test
+var npm = require("../../")
+var osenv = require("osenv")
+var path = require("path")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var mkdirp = require("mkdirp")
+var pkg = path.resolve(__dirname, "404-parent")
var mr = require("npm-registry-mock")
-test('404-parent: if parent exists, specify parent in error message', function(t) {
+test("404-parent: if parent exists, specify parent in error message", function(t) {
setup()
- rimraf.sync(path.resolve(pkg, 'node_modules'))
+ rimraf.sync(path.resolve(pkg, "node_modules"))
performInstall(function(err) {
t.ok(err instanceof Error)
- t.pass('error was returned')
- t.ok(err.parent === '404-parent-test')
+ t.pass("error was returned")
+ t.ok(err.parent === "404-parent-test")
t.end()
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
t.end()
@@ -28,16 +28,16 @@ test('cleanup', function(t) {
function setup() {
mkdirp.sync(pkg)
- mkdirp.sync(path.resolve(pkg, 'cache'))
- fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify({
- author: 'Evan Lucas',
- name: '404-parent-test',
- version: '0.0.0',
- description: 'Test for 404-parent',
+ mkdirp.sync(path.resolve(pkg, "cache"))
+ fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify({
+ author: "Evan Lucas",
+ name: "404-parent-test",
+ version: "0.0.0",
+ description: "Test for 404-parent",
dependencies: {
- 'test-npm-404-parent-test': '*'
+ "test-npm-404-parent-test": "*"
}
- }), 'utf8')
+ }), "utf8")
process.chdir(pkg)
}
diff --git a/test/tap/cache-add-unpublished.js b/test/tap/cache-add-unpublished.js
index e31321314..a4b5276d6 100644
--- a/test/tap/cache-add-unpublished.js
+++ b/test/tap/cache-add-unpublished.js
@@ -1,5 +1,5 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
+var common = require("../common-tap.js")
+var test = require("tap").test
var server
diff --git a/test/tap/config-meta.js b/test/tap/config-meta.js
index 26ca6f2b0..85768e876 100644
--- a/test/tap/config-meta.js
+++ b/test/tap/config-meta.js
@@ -51,16 +51,16 @@ test("get files", function (t) {
test("get lines", function (t) {
FILES.forEach(function (f) {
- var lines = fs.readFileSync(f, 'utf8').split(/\r|\n/)
+ var lines = fs.readFileSync(f, "utf8").split(/\r|\n/)
lines.forEach(function (l, i) {
var matches = l.split(/conf(?:ig)?\.get\(/g)
matches.shift()
matches.forEach(function (m) {
- m = m.split(')').shift()
+ m = m.split(")").shift()
var literal = m.match(/^['"].+['"]$/)
if (literal) {
m = m.slice(1, -1)
- if (!m.match(/^\_/) && m !== 'argv')
+ if (!m.match(/^\_/) && m !== "argv")
CONFS[m] = {
file: f,
line: i
@@ -81,10 +81,9 @@ test("get docs", function (t) {
for (var i = 0; i < d.length && d[i] !== "## Config Settings"; i++);
i++
// now gather up all the ^###\s lines until the next ^##\s
- var doclines = []
for (; i < d.length && !d[i].match(/^## /); i++) {
if (d[i].match(/^### /))
- DOC[ d[i].replace(/^### /, '').trim() ] = true
+ DOC[ d[i].replace(/^### /, "").trim() ] = true
}
t.pass("read the docs")
t.end()
@@ -94,35 +93,34 @@ test("check configs", function (t) {
var defs = require("npmconf/config-defs.js")
var types = Object.keys(defs.types)
var defaults = Object.keys(defs.defaults)
-
- for (var c in CONFS) {
- if (CONFS[c].file.indexOf(lib) === 0) {
- t.ok(DOC[c], "should be documented " + c + " "
- + CONFS[c].file + ":" + CONFS[c].line)
- t.ok(types.indexOf(c) !== -1, "should be defined in npmconf " + c)
- t.ok(defaults.indexOf(c) !== -1, "should have default in npmconf " + c)
+ for (var c1 in CONFS) {
+ if (CONFS[c1].file.indexOf(lib) === 0) {
+ t.ok(DOC[c1], "should be documented " + c1 + " "
+ + CONFS[c1].file + ":" + CONFS[c1].line)
+ t.ok(types.indexOf(c1) !== -1, "should be defined in npmconf " + c1)
+ t.ok(defaults.indexOf(c1) !== -1, "should have default in npmconf " + c1)
}
}
- for (var c in DOC) {
- if (c !== "versions" && c !== "version" && c !== "init.version") {
- t.ok(CONFS[c], "config in doc should be used somewhere " + c)
- t.ok(types.indexOf(c) !== -1, "should be defined in npmconf " + c)
- t.ok(defaults.indexOf(c) !== -1, "should have default in npmconf " + c)
+ for (var c2 in DOC) {
+ if (c2 !== "versions" && c2 !== "version" && c2 !== "init.version") {
+ t.ok(CONFS[c2], "config in doc should be used somewhere " + c2)
+ t.ok(types.indexOf(c2) !== -1, "should be defined in npmconf " + c2)
+ t.ok(defaults.indexOf(c2) !== -1, "should have default in npmconf " + c2)
}
}
types.forEach(function(c) {
- if (!c.match(/^\_/) && c !== 'argv' && !c.match(/^versions?$/)) {
- t.ok(DOC[c], 'defined type should be documented ' + c)
- t.ok(CONFS[c], 'defined type should be used ' + c)
+ if (!c.match(/^\_/) && c !== "argv" && !c.match(/^versions?$/)) {
+ t.ok(DOC[c], "defined type should be documented " + c)
+ t.ok(CONFS[c], "defined type should be used " + c)
}
})
defaults.forEach(function(c) {
- if (!c.match(/^\_/) && c !== 'argv' && !c.match(/^versions?$/)) {
- t.ok(DOC[c], 'defaulted type should be documented ' + c)
- t.ok(CONFS[c], 'defaulted type should be used ' + c)
+ if (!c.match(/^\_/) && c !== "argv" && !c.match(/^versions?$/)) {
+ t.ok(DOC[c], "defaulted type should be documented " + c)
+ t.ok(CONFS[c], "defaulted type should be used " + c)
}
})
diff --git a/test/tap/dedupe.js b/test/tap/dedupe.js
index 18ee110c8..3572cda99 100644
--- a/test/tap/dedupe.js
+++ b/test/tap/dedupe.js
@@ -2,19 +2,20 @@ var test = require("tap").test
, fs = require("fs")
, path = require("path")
, existsSync = fs.existsSync || path.existsSync
- , npm = require("../../")
, rimraf = require("rimraf")
, mr = require("npm-registry-mock")
- , common = require('../common-tap.js')
+ , common = require("../common-tap.js")
-var EXEC_OPTS = { }
+var EXEC_OPTS = {}
test("dedupe finds the common module and moves it up one level", function (t) {
setup(function (s) {
- common.npm(['install', '.', '--registry', common.registry], EXEC_OPTS, function(err, code) {
- t.equal(code, 0)
- common.npm(['dedupe'], EXEC_OPTS, function(err, code) {
- t.equal(code, 0)
+ common.npm(["install", ".", "--registry", common.registry], EXEC_OPTS, function(err, code) {
+ t.ifError(err, "successfully installed directory")
+ t.equal(code, 0, "npm install exited with code")
+ common.npm(["dedupe"], {}, function(err, code) {
+ t.ifError(err, "successfully deduped against previous install")
+ t.notOk(code, "npm dedupe exited with code")
t.ok(existsSync(path.join(__dirname, "dedupe", "node_modules", "minimist")))
t.ok(!existsSync(path.join(__dirname, "dedupe", "node_modules", "checker")))
s.close() // shutdown mock registry.
diff --git a/test/tap/false_name.js b/test/tap/false_name.js
index 5ab1a67ec..a0a05d972 100644
--- a/test/tap/false_name.js
+++ b/test/tap/false_name.js
@@ -11,12 +11,13 @@ var test = require("tap").test
, fs = require("fs")
, path = require("path")
, existsSync = fs.existsSync || path.existsSync
- , spawn = require("child_process").spawn
, npm = require("../../")
, rimraf = require("rimraf")
, common = require("../common-tap.js")
, mr = require("npm-registry-mock")
- , pkg = __dirname + "/false_name"
+ , pkg = path.resolve(__dirname, "false_name")
+ , cache = path.resolve(pkg, "cache")
+ , nodeModules = path.resolve(pkg, "node_modules")
test("not every pkg.name can be required", function (t) {
rimraf.sync(pkg + "/cache")
@@ -35,17 +36,17 @@ test("not every pkg.name can be required", function (t) {
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/cache")
- rimraf.sync(pkg + "/node_modules")
+ rimraf.sync(cache)
+ rimraf.sync(nodeModules)
t.end()
})
function setup (cb) {
process.chdir(pkg)
- npm.load({cache: pkg + "/cache", registry: common.registry},
+ npm.load({cache: cache, registry: common.registry},
function () {
- rimraf.sync(pkg + "/node_modules")
- fs.mkdirSync(pkg + "/node_modules")
+ rimraf.sync(nodeModules)
+ fs.mkdirSync(nodeModules)
cb()
})
}
diff --git a/test/tap/git-cache-locking.js b/test/tap/git-cache-locking.js
index b9b328f30..3e93c1b57 100644
--- a/test/tap/git-cache-locking.js
+++ b/test/tap/git-cache-locking.js
@@ -15,7 +15,7 @@ test("setup", function (t) {
mkdirp.sync(pkg)
mkdirp.sync(cache)
mkdirp.sync(tmp)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ mkdirp.sync(path.resolve(pkg, "node_modules"))
t.end()
})
@@ -29,10 +29,10 @@ test("git-cache-locking: install a git dependency", function (t) {
var child = spawn(node, [npm, "install", "git://github.com/nigelzor/npm-4503-c.git"], {
cwd: pkg,
env: {
- npm_config_cache: cache,
- npm_config_tmp: tmp,
- npm_config_prefix: pkg,
- npm_config_global: "false",
+ "npm_config_cache": cache,
+ "npm_config_tmp": tmp,
+ "npm_config_prefix": pkg,
+ "npm_config_global": "false",
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
@@ -46,7 +46,7 @@ test("git-cache-locking: install a git dependency", function (t) {
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
rimraf.sync(pkg)
t.end()
})
diff --git a/test/tap/global-prefix-set-in-userconfig.js b/test/tap/global-prefix-set-in-userconfig.js
index 85fa4f610..f820a2772 100644
--- a/test/tap/global-prefix-set-in-userconfig.js
+++ b/test/tap/global-prefix-set-in-userconfig.js
@@ -15,9 +15,9 @@ test("setup", function (t) {
test("run command", function (t) {
var args = ["prefix", "-g", "--userconfig=" + rcfile]
- common.npm(args, {env: {}}, function (er, code, so, se) {
+ common.npm(args, {env: {}}, function (er, code, so) {
if (er) throw er
- t.equal(code, 0)
+ t.notOk(code, "npm prefix exited with code 0")
t.equal(so.trim(), prefix)
t.end()
})
diff --git a/test/tap/ignore-install-link.js b/test/tap/ignore-install-link.js
index 44ae54153..45db51d30 100644
--- a/test/tap/ignore-install-link.js
+++ b/test/tap/ignore-install-link.js
@@ -52,7 +52,7 @@ test("ignore install if package is linked", function (t) {
stdio: "inherit"
}, function (er, code) {
if (er) throw er
- t.equal(code, 0)
+ t.equal(code, 0, "npm install exited with code")
t.end()
})
})
diff --git a/test/tap/ignore-scripts.js b/test/tap/ignore-scripts.js
index 9218b7e41..d248d764b 100644
--- a/test/tap/ignore-scripts.js
+++ b/test/tap/ignore-scripts.js
@@ -1,24 +1,24 @@
var common = require("../common-tap")
var test = require("tap").test
-var npm = require.resolve("../../bin/npm-cli.js")
-
-var node = process.execPath
+var path = require("path")
// ignore-scripts/package.json has scripts that always exit with non-zero error
// codes. The "install" script is omitted so that npm tries to run node-gyp,
// which should also fail.
-var pkg = __dirname + "/ignore-scripts"
+var pkg = path.resolve(__dirname, "ignore-scripts")
test("ignore-scripts: install using the option", function(t) {
createChild(["install", "--ignore-scripts"], function(err, code) {
- t.equal(code, 0)
+ t.ifError(err, "install with scripts ignored finished successfully")
+ t.equal(code, 0, "npm install exited with code")
t.end()
})
})
test("ignore-scripts: install NOT using the option", function(t) {
createChild(["install"], function(err, code) {
- t.notEqual(code, 0)
+ t.ifError(err, "install with scripts successful")
+ t.notEqual(code, 0, "npm install exited with code")
t.end()
})
})
@@ -37,7 +37,8 @@ var scripts = [
scripts.forEach(function(script) {
test("ignore-scripts: run-script "+script+" using the option", function(t) {
createChild(["--ignore-scripts", "run-script", script], function(err, code) {
- t.equal(code, 0)
+ t.ifError(err, "run-script " + script + " with ignore-scripts successful")
+ t.equal(code, 0, "npm run-script exited with code")
t.end()
})
})
@@ -46,7 +47,8 @@ scripts.forEach(function(script) {
scripts.forEach(function(script) {
test("ignore-scripts: run-script "+script+" NOT using the option", function(t) {
createChild(["run-script", script], function(err, code) {
- t.notEqual(code, 0)
+ t.ifError(err, "run-script " + script + " finished successfully")
+ t.notEqual(code, 0, "npm run-script exited with code")
t.end()
})
})
@@ -57,7 +59,7 @@ function createChild (args, cb) {
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH,
- npm_config_loglevel: "silent"
+ "npm_config_loglevel": "silent"
}
if (process.platform === "win32")
diff --git a/test/tap/ignore-shrinkwrap.js b/test/tap/ignore-shrinkwrap.js
index 48d8b2272..ccc335beb 100644
--- a/test/tap/ignore-shrinkwrap.js
+++ b/test/tap/ignore-shrinkwrap.js
@@ -4,7 +4,6 @@ var pkg = require("path").join(__dirname,"ignore-shrinkwrap")
var mr = require("npm-registry-mock")
-var child
var spawn = require("child_process").spawn
var npm = require.resolve("../../bin/npm-cli.js")
var node = process.execPath
@@ -18,7 +17,7 @@ var customMocks = {
test("ignore-shrinkwrap: using the option", function (t) {
mr({port: common.port, mocks: customMocks}, function (s) {
- s._server.on("request", function (req, res) {
+ s._server.on("request", function (req) {
switch (req.url) {
case "/shrinkwrap.js":
t.fail()
@@ -28,7 +27,7 @@ test("ignore-shrinkwrap: using the option", function (t) {
}
})
var child = createChild(true)
- child.on("close", function (m) {
+ child.on("close", function () {
s.close()
t.end()
})
@@ -37,7 +36,7 @@ test("ignore-shrinkwrap: using the option", function (t) {
test("ignore-shrinkwrap: NOT using the option", function (t) {
mr({port: common.port, mocks: customMocks}, function (s) {
- s._server.on("request", function (req, res) {
+ s._server.on("request", function (req) {
switch (req.url) {
case "/shrinkwrap.js":
t.pass("shrinkwrap used")
@@ -47,7 +46,7 @@ test("ignore-shrinkwrap: NOT using the option", function (t) {
}
})
var child = createChild(false)
- child.on("close", function (m) {
+ child.on("close", function () {
s.close()
t.end()
})
@@ -65,9 +64,9 @@ function createChild (ignoreShrinkwrap) {
return spawn(node, args, {
cwd: pkg,
env: {
- npm_config_registry: common.registry,
- npm_config_cache_lock_stale: 1000,
- npm_config_cache_lock_wait: 1000,
+ "npm_config_registry": common.registry,
+ "npm_config_cache_lock_stale": 1000,
+ "npm_config_cache_lock_wait": 1000,
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
diff --git a/test/tap/install-at-locally.js b/test/tap/install-at-locally.js
index 5801cafad..02874d0cd 100644
--- a/test/tap/install-at-locally.js
+++ b/test/tap/install-at-locally.js
@@ -1,42 +1,42 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var pkg = path.join(__dirname, 'install-at-locally')
+var common = require("../common-tap.js")
+var test = require("tap").test
+var path = require("path")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var mkdirp = require("mkdirp")
+var pkg = path.join(__dirname, "install-at-locally")
var EXEC_OPTS = { }
test("setup", function (t) {
mkdirp.sync(pkg)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ mkdirp.sync(path.resolve(pkg, "node_modules"))
process.chdir(pkg)
t.end()
})
-test('"npm install ./package@1.2.3" should install local pkg', function(t) {
- common.npm(['install', './package@1.2.3'], EXEC_OPTS, function(err, code) {
- var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
- t.equal(code, 0);
- t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
+test("\"npm install ./package@1.2.3\" should install local pkg", function(t) {
+ common.npm(["install", "./package@1.2.3"], EXEC_OPTS, function(err, code) {
+ var p = path.resolve(pkg, "node_modules/install-at-locally/package.json")
+ t.ifError(err, "install local package successful")
+ t.equal(code, 0, "npm install exited with code")
+ t.ok(JSON.parse(fs.readFileSync(p, "utf8")))
t.end()
})
})
-test('"npm install install/at/locally@./package@1.2.3" should install local pkg', function(t) {
- common.npm(['install', './package@1.2.3'], EXEC_OPTS, function(err, code) {
- var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
- t.equal(code, 0);
- t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
+test("\"npm install install/at/locally@./package@1.2.3\" should install local pkg", function(t) {
+ common.npm(["install", "./package@1.2.3"], EXEC_OPTS, function(err, code) {
+ var p = path.resolve(pkg, "node_modules/install-at-locally/package.json")
+ t.ifError(err, "install local package in explicit directory successful")
+ t.equal(code, 0, "npm install exited with code")
+ t.ok(JSON.parse(fs.readFileSync(p, "utf8")))
t.end()
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
process.chdir(__dirname)
- rimraf.sync(path.resolve(pkg, 'node_modules'))
+ rimraf.sync(path.resolve(pkg, "node_modules"))
t.end()
})
-
diff --git a/test/tap/install-cli-production.js b/test/tap/install-cli-production.js
index 3b26bebb0..00c935527 100644
--- a/test/tap/install-cli-production.js
+++ b/test/tap/install-cli-production.js
@@ -1,11 +1,10 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var pkg = path.join(__dirname, 'install-cli-production')
+var common = require("../common-tap.js")
+var test = require("tap").test
+var path = require("path")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var mkdirp = require("mkdirp")
+var pkg = path.join(__dirname, "install-cli-production")
var EXEC_OPTS = {
cwd: pkg
@@ -13,32 +12,33 @@ var EXEC_OPTS = {
test("setup", function(t) {
mkdirp.sync(pkg)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ mkdirp.sync(path.resolve(pkg, "node_modules"))
process.chdir(pkg)
t.end()
})
-test('"npm install --production" should install dependencies', function(t) {
- common.npm(['install', '--production'], EXEC_OPTS, function(err, code) {
- t.equal(code, 0)
- var p = path.resolve(pkg, 'node_modules/dependency/package.json')
- t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
+test("\"npm install --production\" should install dependencies", function(t) {
+ common.npm(["install", "--production"], EXEC_OPTS, function(err, code) {
+ t.ifError(err, "install production successful")
+ t.equal(code, 0, "npm install exited with code")
+ var p = path.resolve(pkg, "node_modules/dependency/package.json")
+ t.ok(JSON.parse(fs.readFileSync(p, "utf8")))
t.end()
})
})
-test('"npm install --production" should not install dev dependencies', function(t) {
- common.npm(['install', '--production'], EXEC_OPTS, function(err, code) {
- t.equal(code, 0)
- var p = path.resolve(pkg, 'node_modules/dev-dependency/package.json')
- t.ok(!fs.existsSync(p), '')
+test("\"npm install --production\" should not install dev dependencies", function(t) {
+ common.npm(["install", "--production"], EXEC_OPTS, function(err, code) {
+ t.ifError(err, "install production successful")
+ t.equal(code, 0, "npm install exited with code")
+ var p = path.resolve(pkg, "node_modules/dev-dependency/package.json")
+ t.ok(!fs.existsSync(p), "")
t.end()
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
process.chdir(__dirname)
- rimraf.sync(path.resolve(pkg, 'node_modules'))
+ rimraf.sync(path.resolve(pkg, "node_modules"))
t.end()
})
-
diff --git a/test/tap/install-cli-unicode.js b/test/tap/install-cli-unicode.js
index 6eea4a302..8ee6a2f6a 100644
--- a/test/tap/install-cli-unicode.js
+++ b/test/tap/install-cli-unicode.js
@@ -1,26 +1,24 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var mkdirp = require('mkdirp')
-var mr = require('npm-registry-mock')
+var common = require("../common-tap.js")
+var test = require("tap").test
+var mr = require("npm-registry-mock")
var path = require("path")
-var pkg = __dirname + '/install-cli'
-var NPM_BIN = __dirname + '/../../bin/npm-cli.js'
+var pkg = path.resolve(__dirname, "install-cli")
function hasOnlyAscii (s) {
- return /^[\000-\177]*$/.test(s) ;
+ return /^[\000-\177]*$/.test(s)
}
var EXEC_OPTS = {
- cwd : pkg,
+ cwd : pkg
}
-test('does not use unicode with --unicode false', function (t) {
- t.plan(4)
+test("does not use unicode with --unicode false", function (t) {
+ t.plan(5)
mr(common.port, function (s) {
- common.npm(['install', '--unicode', 'false', 'read'], EXEC_OPTS, function(err, code, stdout, stderr) {
- t.equal(code, 0)
+ common.npm(["install", "--unicode", "false", "read"], EXEC_OPTS, function(err, code, stdout) {
+ t.ifError(err, "install package read without unicode success")
+ t.notOk(code, "npm install exited with code 0")
t.ifError(err)
t.ok(stdout, stdout.length)
t.ok(hasOnlyAscii(stdout))
@@ -29,10 +27,11 @@ test('does not use unicode with --unicode false', function (t) {
})
})
-test('cleanup', function (t) {
+test("cleanup", function (t) {
mr(common.port, function (s) {
- common.npm(['uninstall', 'read'], EXEC_OPTS, function(err, code, stdout, stderr) {
- t.equal(code, 0)
+ common.npm(["uninstall", "read"], EXEC_OPTS, function(err, code) {
+ t.ifError(err, "uninstall read package success")
+ t.notOk(code, "npm uninstall exited with code 0")
s.close()
})
})
diff --git a/test/tap/install-from-local.js b/test/tap/install-from-local.js
index 5db715637..d1fbb3b90 100644
--- a/test/tap/install-from-local.js
+++ b/test/tap/install-from-local.js
@@ -1,6 +1,5 @@
var common = require("../common-tap")
var test = require("tap").test
-var npm = require("../../")
var path = require("path")
var fs = require("fs")
var rimraf = require("rimraf")
@@ -15,7 +14,8 @@ test("setup", function (t) {
test('"npm install" should install local packages', function (t) {
common.npm(["install", "."], EXEC_OPTS, function (err, code) {
- t.equal(code, 0)
+ t.ifError(err, "error should not exist")
+ t.notOk(code, "npm install exited with code 0")
var dependencyPackageJson = path.resolve(pkg, "node_modules/package-local-dependency/package.json")
t.ok(
JSON.parse(fs.readFileSync(dependencyPackageJson, "utf8")),
diff --git a/test/tap/install-save-exact.js b/test/tap/install-save-exact.js
index c9f486660..daad03f09 100644
--- a/test/tap/install-save-exact.js
+++ b/test/tap/install-save-exact.js
@@ -1,40 +1,41 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var pkg = path.join(__dirname, 'install-save-exact')
+var common = require("../common-tap.js")
+var test = require("tap").test
+var npm = require("../../")
+var path = require("path")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var mkdirp = require("mkdirp")
+var pkg = path.join(__dirname, "install-save-exact")
var mr = require("npm-registry-mock")
test("setup", function (t) {
mkdirp.sync(pkg)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ mkdirp.sync(path.resolve(pkg, "node_modules"))
process.chdir(pkg)
t.end()
})
-test('"npm install --save --save-exact should install local pkg', function(t) {
+test("\"npm install --save --save-exact\" should install local pkg", function(t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
+ loglevel: "silent",
registry: common.registry }, function(err) {
t.ifError(err)
- npm.config.set('save', true)
- npm.config.set('save-exact', true)
- npm.commands.install(['underscore@1.3.1'], function(err) {
+ npm.config.set("save", true)
+ npm.config.set("save-exact", true)
+ npm.commands.install(["underscore@1.3.1"], function(err) {
t.ifError(err)
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
+ var p = path.resolve(pkg, "node_modules/underscore/package.json")
t.ok(JSON.parse(fs.readFileSync(p)))
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ p = path.resolve(pkg, "package.json")
+ var pkgJson = JSON.parse(fs.readFileSync(p, "utf8"))
t.deepEqual(pkgJson.dependencies, {
- 'underscore': '1.3.1'
- }, 'Underscore dependency should specify exactly 1.3.1')
- npm.config.set('save', undefined)
- npm.config.set('save-exact', undefined)
+ "underscore": "1.3.1"
+ }, "Underscore dependency should specify exactly 1.3.1")
+ npm.config.set("save", undefined)
+ npm.config.set("save-exact", undefined)
s.close()
t.end()
})
@@ -42,50 +43,50 @@ test('"npm install --save --save-exact should install local pkg', function(t) {
})
})
-test('"npm install --save-dev --save-exact should install local pkg', function(t) {
+test("\"npm install --save-dev --save-exact\" should install local pkg", function(t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
+ loglevel: "silent",
registry: common.registry }, function(err) {
t.ifError(err)
- npm.config.set('save-dev', true)
- npm.config.set('save-exact', true)
- npm.commands.install(['underscore@1.3.1'], function(err) {
+ npm.config.set("save-dev", true)
+ npm.config.set("save-exact", true)
+ npm.commands.install(["underscore@1.3.1"], function(err) {
t.ifError(err)
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
+ var p = path.resolve(pkg, "node_modules/underscore/package.json")
t.ok(JSON.parse(fs.readFileSync(p)))
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ p = path.resolve(pkg, "package.json")
+ var pkgJson = JSON.parse(fs.readFileSync(p, "utf8"))
console.log(pkgJson)
t.deepEqual(pkgJson.devDependencies, {
- 'underscore': '1.3.1'
- }, 'underscore devDependency should specify exactly 1.3.1')
+ "underscore": "1.3.1"
+ }, "underscore devDependency should specify exactly 1.3.1")
s.close()
- npm.config.set('save-dev', undefined)
- npm.config.set('save-exact', undefined)
+ npm.config.set("save-dev", undefined)
+ npm.config.set("save-exact", undefined)
t.end()
})
})
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
process.chdir(__dirname)
- rimraf.sync(path.resolve(pkg, 'node_modules'))
- rimraf.sync(path.resolve(pkg, 'cache'))
+ rimraf.sync(path.resolve(pkg, "node_modules"))
+ rimraf.sync(path.resolve(pkg, "cache"))
resetPackageJSON(pkg)
t.end()
})
function resetPackageJSON(pkg) {
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8"))
delete pkgJson.dependencies
delete pkgJson.devDependencies
delete pkgJson.optionalDependencies
var json = JSON.stringify(pkgJson, null, 2) + "\n"
- fs.writeFileSync(pkg + '/package.json', json, "ascii")
+ var p = path.resolve(pkg, "package.json")
+ fs.writeFileSync(p, json, "ascii")
}
-
-
diff --git a/test/tap/install-save-local.js b/test/tap/install-save-local.js
index 688508342..7f6cea2f5 100644
--- a/test/tap/install-save-local.js
+++ b/test/tap/install-save-local.js
@@ -1,6 +1,5 @@
-var common = require('../common-tap.js')
+var common = require("../common-tap.js")
var test = require("tap").test
-var npm = require("../../")
var path = require("path")
var fs = require("fs")
var rimraf = require("rimraf")
@@ -17,7 +16,7 @@ test('"npm install --save ../local/path" should install local package and save t
resetPackageJSON(pkg)
common.npm(["install", "--save", "../package-local-dependency"], EXEC_OPTS, function(err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm install exited with code 0")
var dependencyPackageJson = path.resolve(pkg, "node_modules/package-local-dependency/package.json")
t.ok(JSON.parse(fs.readFileSync(dependencyPackageJson, "utf8")))
@@ -34,7 +33,7 @@ test('"npm install --save-dev ../local/path" should install local package and sa
resetPackageJSON(pkg)
common.npm(["install", "--save-dev", "../package-local-dev-dependency"], EXEC_OPTS, function(err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm install exited with code 0")
var dependencyPackageJson = path.resolve(pkg, "node_modules/package-local-dev-dependency/package.json")
t.ok(JSON.parse(fs.readFileSync(dependencyPackageJson, "utf8")))
diff --git a/test/tap/install-save-prefix.js b/test/tap/install-save-prefix.js
index 0e78005b6..507c7e76b 100644
--- a/test/tap/install-save-prefix.js
+++ b/test/tap/install-save-prefix.js
@@ -1,39 +1,39 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var pkg = path.join(__dirname, 'install-save-prefix')
+var common = require("../common-tap.js")
+var test = require("tap").test
+var npm = require("../../")
+var path = require("path")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var mkdirp = require("mkdirp")
+var pkg = path.join(__dirname, "install-save-prefix")
var mr = require("npm-registry-mock")
test("setup", function (t) {
mkdirp.sync(pkg)
- mkdirp.sync(path.resolve(pkg, 'node_modules'))
+ mkdirp.sync(path.resolve(pkg, "node_modules"))
process.chdir(pkg)
t.end()
})
-test('"npm install --save with default save-prefix should install local pkg versioned to allow minor updates', function(t) {
+test("npm install --save with default save-prefix should install local pkg versioned to allow minor updates", function(t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
- 'save-prefix': '^',
+ loglevel: "silent",
+ "save-prefix": "^",
registry: common.registry }, function(err) {
t.ifError(err)
- npm.config.set('save', true)
- npm.commands.install(['underscore@latest'], function(err) {
+ npm.config.set("save", true)
+ npm.commands.install(["underscore@latest"], function(err) {
t.ifError(err)
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
+ var p = path.resolve(pkg, "node_modules/underscore/package.json")
t.ok(JSON.parse(fs.readFileSync(p)))
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8"))
t.deepEqual(pkgJson.dependencies, {
- 'underscore': '^1.5.1'
- }, 'Underscore dependency should specify ^1.5.1')
- npm.config.set('save', undefined)
+ "underscore": "^1.5.1"
+ }, "Underscore dependency should specify ^1.5.1")
+ npm.config.set("save", undefined)
s.close()
t.end()
})
@@ -41,25 +41,25 @@ test('"npm install --save with default save-prefix should install local pkg vers
})
})
-test('"npm install --save-dev with default save-prefix should install local pkg to dev dependencies versioned to allow minor updates', function(t) {
+test("npm install --save-dev with default save-prefix should install local pkg to dev dependencies versioned to allow minor updates", function(t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
- 'save-prefix': '^',
+ loglevel: "silent",
+ "save-prefix": "^",
registry: common.registry }, function(err) {
t.ifError(err)
- npm.config.set('save-dev', true)
- npm.commands.install(['underscore@1.3.1'], function(err) {
+ npm.config.set("save-dev", true)
+ npm.commands.install(["underscore@1.3.1"], function(err) {
t.ifError(err)
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
+ var p = path.resolve(pkg, "node_modules/underscore/package.json")
t.ok(JSON.parse(fs.readFileSync(p)))
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8"))
t.deepEqual(pkgJson.devDependencies, {
- 'underscore': '^1.3.1'
- }, 'Underscore devDependency should specify ^1.3.1')
- npm.config.set('save-dev', undefined)
+ "underscore": "^1.3.1"
+ }, "Underscore devDependency should specify ^1.3.1")
+ npm.config.set("save-dev", undefined)
s.close()
t.end()
})
@@ -67,26 +67,26 @@ test('"npm install --save-dev with default save-prefix should install local pkg
})
})
-test('"npm install --save with "~" save-prefix should install local pkg versioned to allow patch updates', function(t) {
+test("npm install --save with \"~\" save-prefix should install local pkg versioned to allow patch updates", function(t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
+ loglevel: "silent",
registry: common.registry }, function(err) {
t.ifError(err)
- npm.config.set('save', true)
- npm.config.set('save-prefix', '~')
- npm.commands.install(['underscore@1.3.1'], function(err) {
+ npm.config.set("save", true)
+ npm.config.set("save-prefix", "~")
+ npm.commands.install(["underscore@1.3.1"], function(err) {
t.ifError(err)
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
+ var p = path.resolve(pkg, "node_modules/underscore/package.json")
t.ok(JSON.parse(fs.readFileSync(p)))
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8"))
t.deepEqual(pkgJson.dependencies, {
- 'underscore': '~1.3.1'
- }, 'Underscore dependency should specify ~1.3.1')
- npm.config.set('save', undefined)
- npm.config.set('save-prefix', undefined)
+ "underscore": "~1.3.1"
+ }, "Underscore dependency should specify ~1.3.1")
+ npm.config.set("save", undefined)
+ npm.config.set("save-prefix", undefined)
s.close()
t.end()
})
@@ -94,26 +94,26 @@ test('"npm install --save with "~" save-prefix should install local pkg versione
})
})
-test('"npm install --save-dev with "~" save-prefix should install local pkg to dev dependencies versioned to allow patch updates', function(t) {
+test("npm install --save-dev with \"~\" save-prefix should install local pkg to dev dependencies versioned to allow patch updates", function(t) {
resetPackageJSON(pkg)
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
+ loglevel: "silent",
registry: common.registry }, function(err) {
t.ifError(err)
- npm.config.set('save-dev', true)
- npm.config.set('save-prefix', '~')
- npm.commands.install(['underscore@1.3.1'], function(err) {
+ npm.config.set("save-dev", true)
+ npm.config.set("save-prefix", "~")
+ npm.commands.install(["underscore@1.3.1"], function(err) {
t.ifError(err)
- var p = path.resolve(pkg, 'node_modules/underscore/package.json')
+ var p = path.resolve(pkg, "node_modules/underscore/package.json")
t.ok(JSON.parse(fs.readFileSync(p)))
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8"))
t.deepEqual(pkgJson.devDependencies, {
- 'underscore': '~1.3.1'
- }, 'Underscore devDependency should specify ~1.3.1')
- npm.config.set('save-dev', undefined)
- npm.config.set('save-prefix', undefined)
+ "underscore": "~1.3.1"
+ }, "Underscore devDependency should specify ~1.3.1")
+ npm.config.set("save-dev", undefined)
+ npm.config.set("save-prefix", undefined)
s.close()
t.end()
})
@@ -121,21 +121,19 @@ test('"npm install --save-dev with "~" save-prefix should install local pkg to d
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
process.chdir(__dirname)
- rimraf.sync(path.resolve(pkg, 'node_modules'))
- rimraf.sync(path.resolve(pkg, 'cache'))
+ rimraf.sync(path.resolve(pkg, "node_modules"))
+ rimraf.sync(path.resolve(pkg, "cache"))
resetPackageJSON(pkg)
t.end()
})
function resetPackageJSON(pkg) {
- var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8'))
+ var pkgJson = JSON.parse(fs.readFileSync(pkg + "/package.json", "utf8"))
delete pkgJson.dependencies
delete pkgJson.devDependencies
delete pkgJson.optionalDependencies
var json = JSON.stringify(pkgJson, null, 2) + "\n"
- fs.writeFileSync(pkg + '/package.json', json, "ascii")
+ fs.writeFileSync(pkg + "/package.json", json, "ascii")
}
-
-
diff --git a/test/tap/install-scoped-already-installed.js b/test/tap/install-scoped-already-installed.js
index 6ae367e1b..5b5cdb4f0 100644
--- a/test/tap/install-scoped-already-installed.js
+++ b/test/tap/install-scoped-already-installed.js
@@ -6,8 +6,6 @@ var test = require("tap").test
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
-var npm = require("../../")
-
var pkg = join(__dirname, "install-from-local", "package-with-scoped-paths")
var modules = join(pkg, "node_modules")
@@ -24,9 +22,10 @@ test("setup", function (t) {
})
test("installing already installed local scoped package", function (t) {
- common.npm(['install', '--loglevel', 'silent'], EXEC_OPTS, function(err, code, stdout, stderr) {
+ common.npm(["install", "--loglevel", "silent"], EXEC_OPTS, function(err, code, stdout) {
var installed = parseNpmInstallOutput(stdout)
- t.equal(code, 0)
+ t.ifError(err, "error should not exist")
+ t.notOk(code, "npm install exited with code 0")
t.ifError(err, "install ran to completion without error")
t.ok(
existsSync(join(modules, "@scoped", "package", "package.json")),
@@ -35,9 +34,10 @@ test("installing already installed local scoped package", function (t) {
t.ok(contains(installed, "node_modules/@scoped/package"), "installed @scoped/package")
t.ok(contains(installed, "node_modules/package-local-dependency"), "installed package-local-dependency")
- common.npm(['install', '--loglevel', 'silent'], EXEC_OPTS, function(err, code, stdout, stderr) {
+ common.npm(["install", "--loglevel", "silent"], EXEC_OPTS, function(err, code, stdout) {
installed = parseNpmInstallOutput(stdout)
- t.equal(code, 0)
+ t.ifError(err, "error should not exist")
+ t.notOk(code, "npm install exited with code 0")
t.ifError(err, "install ran to completion without error")
@@ -63,10 +63,10 @@ test("cleanup", function(t) {
function contains(list, element) {
for (var i=0; i < list.length; ++i) {
if (list[i] === element) {
- return true;
+ return true
}
}
- return false;
+ return false
}
function parseNpmInstallOutput(stdout) {
diff --git a/test/tap/install-scoped-link.js b/test/tap/install-scoped-link.js
index 53bd49260..d42fbb7a2 100644
--- a/test/tap/install-scoped-link.js
+++ b/test/tap/install-scoped-link.js
@@ -1,15 +1,13 @@
-var common = require('../common-tap.js')
+var common = require("../common-tap.js")
var existsSync = require("fs").existsSync
var join = require("path").join
// var resolve = require("path").resolve
-var exec = require('child_process').exec
+var exec = require("child_process").exec
var test = require("tap").test
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
-var npm = require("../../")
-
var pkg = join(__dirname, "install-scoped")
var work = join(__dirname, "install-scoped-TEST")
var modules = join(work, "node_modules")
@@ -24,9 +22,9 @@ test("setup", function (t) {
})
test("installing package with links", function (t) {
- common.npm(['install', pkg], EXEC_OPTS, function(err, code, stdout, stderr) {
+ common.npm(["install", pkg], EXEC_OPTS, function(err, code) {
t.ifError(err, "install ran to completion without error")
- t.equal(code, 0)
+ t.notOk(code, "npm install exited with code 0")
t.ok(
existsSync(join(modules, "@scoped", "package", "package.json")),
diff --git a/test/tap/install-with-dev-dep-duplicate.js b/test/tap/install-with-dev-dep-duplicate.js
index 22b6b5dd0..d0f86aa77 100644
--- a/test/tap/install-with-dev-dep-duplicate.js
+++ b/test/tap/install-with-dev-dep-duplicate.js
@@ -46,7 +46,7 @@ function setup (cb) {
cleanup()
process.chdir(pkg)
- var opts = { cache: path.resolve(pkg, "cache"), registry: common.registry};
+ var opts = { cache: path.resolve(pkg, "cache"), registry: common.registry}
npm.load(opts, cb)
}
diff --git a/test/tap/invalid-cmd-exit-code.js b/test/tap/invalid-cmd-exit-code.js
index 14db8669e..e9458176d 100644
--- a/test/tap/invalid-cmd-exit-code.js
+++ b/test/tap/invalid-cmd-exit-code.js
@@ -1,5 +1,4 @@
var test = require("tap").test
-var node = process.execPath
var common = require("../common-tap.js")
var opts = { cwd: process.cwd() }
diff --git a/test/tap/lifecycle-path.js b/test/tap/lifecycle-path.js
index 34684a0c3..cf4bbdc99 100644
--- a/test/tap/lifecycle-path.js
+++ b/test/tap/lifecycle-path.js
@@ -2,7 +2,6 @@ var test = require("tap").test
var common = require("../common-tap.js")
var path = require("path")
var rimraf = require("rimraf")
-var mkdirp = require("mkdirp")
var pkg = path.resolve(__dirname, "lifecycle-path")
var fs = require("fs")
var link = path.resolve(pkg, "node-bin")
@@ -28,7 +27,7 @@ test("make sure the path is correct", function (t) {
PATH: PATH,
stdio: [ 0, "pipe", 2 ]
}
- }, function (er, code, stdout, stderr) {
+ }, function (er, code, stdout) {
if (er) throw er
t.equal(code, 0, "exit code")
// remove the banner, we just care about the last line
@@ -58,4 +57,3 @@ test("clean", function (t) {
rimraf.sync(link)
t.end()
})
-
diff --git a/test/tap/lifecycle.js b/test/tap/lifecycle.js
index 288329c24..ba2ac9d88 100644
--- a/test/tap/lifecycle.js
+++ b/test/tap/lifecycle.js
@@ -1,12 +1,12 @@
var test = require("tap").test
-var npm = require('../../')
-var lifecycle = require('../../lib/utils/lifecycle')
+var npm = require("../../")
+var lifecycle = require("../../lib/utils/lifecycle")
test("lifecycle: make env correctly", function (t) {
npm.load({enteente: Infinity}, function() {
var env = lifecycle.makeEnv({}, null, process.env)
- t.equal('Infinity', env.npm_config_enteente)
+ t.equal("Infinity", env.npm_config_enteente)
t.end()
})
})
diff --git a/test/tap/login-always-auth.js b/test/tap/login-always-auth.js
index 3f2001721..5936bd634 100644
--- a/test/tap/login-always-auth.js
+++ b/test/tap/login-always-auth.js
@@ -1,14 +1,11 @@
var fs = require("fs")
var path = require("path")
-var spawn = require("child_process").spawn
var rimraf = require("rimraf")
var mr = require("npm-registry-mock")
var test = require("tap").test
var common = require("../common-tap.js")
-var node = process.execPath
-var npm = require.resolve("../../bin/npm-cli.js")
var opts = {cwd : __dirname}
var outfile = path.resolve(__dirname, "_npmrc")
var responses = {
@@ -29,9 +26,20 @@ function mocks(server) {
test("npm login", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
- var runner = common.npm(['login', '--registry', common.registry, '--loglevel', 'silent', '--userconfig', outfile], opts, function(err, code, stdout, stderr) {
+ var runner = common.npm(
+ [
+ "login",
+ "--registry",
+ common.registry,
+ "--loglevel",
+ "silent",
+ "--userconfig",
+ outfile
+ ],
+ opts,
+ function(err, code) {
t.notOk(code, "exited OK")
- t.notOk(e, "no error output")
+ t.notOk(err, "no error output")
var config = fs.readFileSync(outfile, "utf8")
t.like(config, /:always-auth=false/, "always-auth is scoped and false (by default)")
s.close()
@@ -58,9 +66,21 @@ test("npm login", function (t) {
test("npm login --always-auth", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
- var runner = common.npm(["login", "--registry", common.registry, "--loglevel", "silent", "--userconfig", outfile, "--always-auth"], opts, function(err, code, stdout, stderr) {
+ var runner = common.npm(
+ [
+ "login",
+ "--registry",
+ common.registry,
+ "--loglevel",
+ "silent",
+ "--userconfig",
+ outfile,
+ "--always-auth"
+ ],
+ opts,
+ function(err, code) {
t.notOk(code, "exited OK")
- t.notOk(e, "no error output")
+ t.notOk(err, "no error output")
var config = fs.readFileSync(outfile, "utf8")
t.like(config, /:always-auth=true/, "always-auth is scoped and true")
s.close()
@@ -86,9 +106,21 @@ test("npm login --always-auth", function (t) {
test("npm login --no-always-auth", function (t) {
mr({port : common.port, mocks : mocks}, function (s) {
- var runner = common.npm(["login", "--registry", common.registry, "--loglevel", "silent", "--userconfig", outfile, "--no-always-auth"], opts, function(err, code, stdout, stderr) {
+ var runner = common.npm(
+ [
+ "login",
+ "--registry",
+ common.registry,
+ "--loglevel",
+ "silent",
+ "--userconfig",
+ outfile,
+ "--no-always-auth"
+ ],
+ opts,
+ function(err, code) {
t.notOk(code, "exited OK")
- t.notOk(e, "no error output")
+ t.notOk(err, "no error output")
var config = fs.readFileSync(outfile, "utf8")
t.like(config, /:always-auth=false/, "always-auth is scoped and false")
s.close()
diff --git a/test/tap/ls-depth-cli.js b/test/tap/ls-depth-cli.js
index fcbc4364f..89c4cc354 100644
--- a/test/tap/ls-depth-cli.js
+++ b/test/tap/ls-depth-cli.js
@@ -1,31 +1,27 @@
-var common = require('../common-tap')
- , test = require('tap').test
- , path = require('path')
- , rimraf = require('rimraf')
- , osenv = require('osenv')
- , mkdirp = require('mkdirp')
- , pkg = __dirname + '/ls-depth'
- , cache = pkg + '/cache'
- , tmp = pkg + '/tmp'
- , node = process.execPath
- , npm = path.resolve(__dirname, '../../cli.js')
- , mr = require('npm-registry-mock')
+var common = require("../common-tap")
+ , test = require("tap").test
+ , path = require("path")
+ , rimraf = require("rimraf")
+ , osenv = require("osenv")
+ , mkdirp = require("mkdirp")
+ , pkg = path.resolve(__dirname, "ls-depth")
+ , mr = require("npm-registry-mock")
, opts = {cwd: pkg}
function cleanup () {
process.chdir(osenv.tmpdir())
- rimraf.sync(pkg + '/cache')
- rimraf.sync(pkg + '/tmp')
- rimraf.sync(pkg + '/node_modules')
+ rimraf.sync(pkg + "/cache")
+ rimraf.sync(pkg + "/tmp")
+ rimraf.sync(pkg + "/node_modules")
}
-test('setup', function (t) {
+test("setup", function (t) {
cleanup()
- mkdirp.sync(pkg + '/cache')
- mkdirp.sync(pkg + '/tmp')
+ mkdirp.sync(pkg + "/cache")
+ mkdirp.sync(pkg + "/tmp")
mr(common.port, function (s) {
- var cmd = ['install', '--registry=' + common.registry]
+ var cmd = ["install", "--registry=" + common.registry]
common.npm(cmd, opts, function (er, c) {
if (er) throw er
t.equal(c, 0)
@@ -35,8 +31,8 @@ test('setup', function (t) {
})
})
-test('npm ls --depth=0', function (t) {
- common.npm(['ls', '--depth=0'], opts, function (er, c, out) {
+test("npm ls --depth=0", function (t) {
+ common.npm(["ls", "--depth=0"], opts, function (er, c, out) {
if (er) throw er
t.equal(c, 0)
t.has(out, /test-package-with-one-dep@0\.0\.0/
@@ -47,8 +43,8 @@ test('npm ls --depth=0', function (t) {
})
})
-test('npm ls --depth=1', function (t) {
- common.npm(['ls', '--depth=1'], opts, function (er, c, out) {
+test("npm ls --depth=1", function (t) {
+ common.npm(["ls", "--depth=1"], opts, function (er, c, out) {
if (er) throw er
t.equal(c, 0)
t.has(out, /test-package-with-one-dep@0\.0\.0/
@@ -59,10 +55,10 @@ test('npm ls --depth=1', function (t) {
})
})
-test('npm ls --depth=Infinity', function (t) {
+test("npm ls --depth=Infinity", function (t) {
// travis has a preconfigured depth=0, in general we can not depend
// on the default value in all environments, so explictly set it here
- common.npm(['ls', '--depth=Infinity'], opts, function (er, c, out) {
+ common.npm(["ls", "--depth=Infinity"], opts, function (er, c, out) {
if (er) throw er
t.equal(c, 0)
t.has(out, /test-package-with-one-dep@0\.0\.0/
@@ -73,7 +69,7 @@ test('npm ls --depth=Infinity', function (t) {
})
})
-test('cleanup', function (t) {
+test("cleanup", function (t) {
cleanup()
t.end()
})
diff --git a/test/tap/ls-depth-unmet.js b/test/tap/ls-depth-unmet.js
index 1ac85efc9..37a0cb5fe 100644
--- a/test/tap/ls-depth-unmet.js
+++ b/test/tap/ls-depth-unmet.js
@@ -1,31 +1,30 @@
-var common = require('../common-tap')
- , test = require('tap').test
- , path = require('path')
- , rimraf = require('rimraf')
- , osenv = require('osenv')
- , mkdirp = require('mkdirp')
- , pkg = __dirname + '/ls-depth-unmet'
- , cache = pkg + '/cache'
- , tmp = pkg + '/tmp'
- , node = process.execPath
- , npm = path.resolve(__dirname, '../../cli.js')
- , mr = require('npm-registry-mock')
+var common = require("../common-tap")
+ , test = require("tap").test
+ , path = require("path")
+ , rimraf = require("rimraf")
+ , osenv = require("osenv")
+ , mkdirp = require("mkdirp")
+ , pkg = path.resolve(__dirname, "ls-depth-unmet")
+ , mr = require("npm-registry-mock")
, opts = {cwd: pkg}
+ , cache = path.resolve(pkg, "cache")
+ , tmp = path.resolve(pkg, "tmp")
+ , nodeModules = path.resolve(pkg, "node_modules")
function cleanup () {
process.chdir(osenv.tmpdir())
- rimraf.sync(pkg + '/cache')
- rimraf.sync(pkg + '/tmp')
- rimraf.sync(pkg + '/node_modules')
+ rimraf.sync(cache)
+ rimraf.sync(tmp)
+ rimraf.sync(nodeModules)
}
-test('setup', function (t) {
+test("setup", function (t) {
cleanup()
- mkdirp.sync(pkg + '/cache')
- mkdirp.sync(pkg + '/tmp')
+ mkdirp.sync(cache)
+ mkdirp.sync(tmp)
mr(common.port, function (s) {
- var cmd = ['install', 'underscore@1.3.1', 'mkdirp', 'test-package-with-one-dep', '--registry=' + common.registry]
+ var cmd = ["install", "underscore@1.3.1", "mkdirp", "test-package-with-one-dep", "--registry=" + common.registry]
common.npm(cmd, opts, function (er, c) {
if (er) throw er
t.equal(c, 0)
@@ -35,8 +34,8 @@ test('setup', function (t) {
})
})
-test('npm ls --depth=0', function (t) {
- common.npm(['ls', '--depth=0'], opts, function (er, c, out) {
+test("npm ls --depth=0", function (t) {
+ common.npm(["ls", "--depth=0"], opts, function (er, c, out) {
if (er) throw er
t.equal(c, 1)
t.has(out, /UNMET DEPENDENCY optimist@0\.6\.0/
@@ -53,8 +52,8 @@ test('npm ls --depth=0', function (t) {
})
})
-test('npm ls --depth=1', function (t) {
- common.npm(['ls', '--depth=1'], opts, function (er, c, out) {
+test("npm ls --depth=1", function (t) {
+ common.npm(["ls", "--depth=1"], opts, function (er, c, out) {
if (er) throw er
t.equal(c, 1)
t.has(out, /UNMET DEPENDENCY optimist@0\.6\.0/
@@ -71,10 +70,10 @@ test('npm ls --depth=1', function (t) {
})
})
-test('npm ls --depth=Infinity', function (t) {
+test("npm ls --depth=Infinity", function (t) {
// travis has a preconfigured depth=0, in general we can not depend
// on the default value in all environments, so explictly set it here
- common.npm(['ls', '--depth=Infinity'], opts, function (er, c, out) {
+ common.npm(["ls", "--depth=Infinity"], opts, function (er, c, out) {
if (er) throw er
t.equal(c, 1)
t.has(out, /UNMET DEPENDENCY optimist@0\.6\.0/
@@ -91,7 +90,7 @@ test('npm ls --depth=Infinity', function (t) {
})
})
-test('cleanup', function (t) {
+test("cleanup", function (t) {
cleanup()
t.end()
})
diff --git a/test/tap/ls-no-results.js b/test/tap/ls-no-results.js
index 9792774c6..10f3ce001 100644
--- a/test/tap/ls-no-results.js
+++ b/test/tap/ls-no-results.js
@@ -1,11 +1,11 @@
-var test = require('tap').test
-var spawn = require('child_process').spawn
+var test = require("tap").test
+var spawn = require("child_process").spawn
var node = process.execPath
-var npm = require.resolve('../../')
-var args = [ npm, 'ls', 'ceci n’est pas une package' ]
-test('ls exits non-zero when nothing found', function (t) {
+var npm = require.resolve("../../")
+var args = [ npm, "ls", "ceci n’est pas une package" ]
+test("ls exits non-zero when nothing found", function (t) {
var child = spawn(node, args)
- child.on('exit', function (code) {
+ child.on("exit", function (code) {
t.notEqual(code, 0)
t.end()
})
diff --git a/test/tap/noargs-install-config-save.js b/test/tap/noargs-install-config-save.js
index c821000c2..328da7d17 100644
--- a/test/tap/noargs-install-config-save.js
+++ b/test/tap/noargs-install-config-save.js
@@ -11,8 +11,8 @@ var mr = require("npm-registry-mock")
var spawn = require("child_process").spawn
var node = process.execPath
-var pkg = process.env.npm_config_tmp || "/tmp"
-pkg += path.sep + "noargs-install-config-save"
+var pkg = path.resolve(process.env.npm_config_tmp || "/tmp",
+ "noargs-install-config-save")
function writePackageJson() {
rimraf.sync(pkg)
@@ -26,14 +26,14 @@ function writePackageJson() {
"devDependencies": {
"underscore": "1.3.1"
}
- }), 'utf8')
+ }), "utf8")
}
function createChild (args) {
var env = {
- npm_config_save: true,
- npm_config_registry: common.registry,
- npm_config_cache: pkg + "/cache",
+ "npm_config_save": true,
+ "npm_config_registry": common.registry,
+ "npm_config_cache": pkg + "/cache",
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
@@ -56,7 +56,7 @@ test("does not update the package.json with empty arguments", function (t) {
var child = createChild([npm, "install"])
child.on("close", function () {
var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8"))
- t.ok(text.indexOf('"dependencies') === -1)
+ t.ok(text.indexOf("\"dependencies") === -1)
s.close()
t.end()
})
@@ -71,7 +71,7 @@ test("updates the package.json (adds dependencies) with an argument", function (
var child = createChild([npm, "install", "underscore"])
child.on("close", function () {
var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8"))
- t.ok(text.indexOf('"dependencies') !== -1)
+ t.ok(text.indexOf("\"dependencies") !== -1)
s.close()
t.end()
})
diff --git a/test/tap/npm-api-not-loaded-error.js b/test/tap/npm-api-not-loaded-error.js
index 3fd073110..afedfbcd0 100644
--- a/test/tap/npm-api-not-loaded-error.js
+++ b/test/tap/npm-api-not-loaded-error.js
@@ -21,7 +21,7 @@ test("calling set/get on config pre-load should throw", function (t) {
t.ok(threw, "get before load should throw")
}
- var threw = true
+ threw = true
try {
npm.config.set("foo", "bar")
threw = false
diff --git a/test/tap/optional-metadep-rollback-collision.js b/test/tap/optional-metadep-rollback-collision.js
index 29db793bc..f8645840b 100644
--- a/test/tap/optional-metadep-rollback-collision.js
+++ b/test/tap/optional-metadep-rollback-collision.js
@@ -25,7 +25,7 @@ test("go go test racer", function (t) {
stdio: [ 0, "pipe", 2 ]
}, function (er, code, sout) {
if (er) throw er
- t.equal(code, 0)
+ t.notOk(code, "npm install exited with code 0")
t.equal(sout, "ok\nok\n")
t.notOk(/not ok/.test(sout), "should not contain the string 'not ok'")
t.end()
diff --git a/test/tap/outdated-color.js b/test/tap/outdated-color.js
index ddd05c1ca..787525edf 100644
--- a/test/tap/outdated-color.js
+++ b/test/tap/outdated-color.js
@@ -1,17 +1,16 @@
var common = require("../common-tap.js")
var test = require("tap").test
-var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var mr = require("npm-registry-mock")
-var exec = require('child_process').exec
-var mr = require("npm-registry-mock")
+var path = require("path")
-var pkg = __dirname + '/outdated'
-mkdirp.sync(pkg + "/cache")
+var pkg = path.resolve(__dirname, "outdated")
+var cache = path.resolve(pkg, "cache")
+mkdirp.sync(cache)
var EXEC_OPTS = {
- cwd: pkg,
+ cwd: pkg
}
function hasControlCodes(str) {
@@ -20,20 +19,19 @@ function hasControlCodes(str) {
function ansiTrim (str) {
var r = new RegExp("\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|" +
- "\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
+ "\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g")
return str.replace(r, "")
}
// note hard to automate tests for color = true
// as npm kills the color config when it detects
-// it's not running in a tty
+// it"s not running in a tty
test("does not use ansi styling", function (t) {
t.plan(4)
mr(common.port, function (s) { // create mock registry.
- common.npm(['outdated', '--registry', common.registry, 'underscore'], EXEC_OPTS, function(err, code, stdout, stderr) {
- console.error(stderr);
+ common.npm(["outdated", "--registry", common.registry, "underscore"], EXEC_OPTS, function(err, code, stdout) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm outdated exited with code 0")
t.ok(stdout, stdout.length)
t.ok(!hasControlCodes(stdout))
s.close()
@@ -42,6 +40,6 @@ test("does not use ansi styling", function (t) {
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(cache)
t.end()
})
diff --git a/test/tap/outdated-depth.js b/test/tap/outdated-depth.js
index 7ccc0c625..112f363aa 100644
--- a/test/tap/outdated-depth.js
+++ b/test/tap/outdated-depth.js
@@ -1,37 +1,39 @@
-var common = require('../common-tap')
- , path = require('path')
- , test = require('tap').test
- , rimraf = require('rimraf')
- , npm = require('../../')
- , mr = require('npm-registry-mock')
- , pkg = path.resolve(__dirname, 'outdated-depth')
+var common = require("../common-tap")
+ , path = require("path")
+ , test = require("tap").test
+ , rimraf = require("rimraf")
+ , npm = require("../../")
+ , mr = require("npm-registry-mock")
+ , pkg = path.resolve(__dirname, "outdated-depth")
+ , cache = path.resolve(pkg, "cache")
+ , nodeModules = path.resolve(pkg, "node_modules")
function cleanup () {
- rimraf.sync(pkg + '/node_modules')
- rimraf.sync(pkg + '/cache')
+ rimraf.sync(nodeModules)
+ rimraf.sync(cache)
}
-test('outdated depth zero', function (t) {
+test("outdated depth zero", function (t) {
var expected = [
pkg,
- 'underscore',
- '1.3.1',
- '1.3.1',
- '1.5.1',
- '1.3.1'
+ "underscore",
+ "1.3.1",
+ "1.3.1",
+ "1.5.1",
+ "1.3.1"
]
process.chdir(pkg)
mr(common.port, function (s) {
npm.load({
- cache: pkg + '/cache'
- , loglevel: 'silent'
+ cache: cache
+ , loglevel: "silent"
, registry: common.registry
, depth: 0
}
, function () {
- npm.install('.', function (er) {
+ npm.install(".", function (er) {
if (er) throw new Error(er)
npm.outdated(function (err, d) {
if (err) throw new Error(err)
diff --git a/test/tap/outdated-git.js b/test/tap/outdated-git.js
index 11c204022..cc89ff19d 100644
--- a/test/tap/outdated-git.js
+++ b/test/tap/outdated-git.js
@@ -3,28 +3,29 @@ var test = require("tap").test
var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
-var mr = require("npm-registry-mock")
+var path = require("path")
// config
-var pkg = __dirname + "/outdated-git"
-mkdirp.sync(pkg + "/cache")
+var pkg = path.resolve(__dirname, "outdated-git")
+var cache = path.resolve(pkg, "cache")
+mkdirp.sync(cache)
test("dicovers new versions in outdated", function (t) {
process.chdir(pkg)
t.plan(5)
- npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
+ npm.load({cache: cache, registry: common.registry}, function () {
npm.commands.outdated([], function (er, d) {
- t.equal('git', d[0][3])
- t.equal('git', d[0][4])
- t.equal('git://github.com/robertkowalski/foo-private.git', d[0][5])
- t.equal('git://user:pass@github.com/robertkowalski/foo-private.git', d[1][5])
- t.equal('git+https://github.com/robertkowalski/foo', d[2][5])
+ t.equal("git", d[0][3])
+ t.equal("git", d[0][4])
+ t.equal("git://github.com/robertkowalski/foo-private.git", d[0][5])
+ t.equal("git://user:pass@github.com/robertkowalski/foo-private.git", d[1][5])
+ t.equal("git+https://github.com/robertkowalski/foo", d[2][5])
})
})
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(cache)
t.end()
})
diff --git a/test/tap/outdated-include-devdependencies.js b/test/tap/outdated-include-devdependencies.js
index b78948a24..bdb656ff1 100644
--- a/test/tap/outdated-include-devdependencies.js
+++ b/test/tap/outdated-include-devdependencies.js
@@ -4,15 +4,17 @@ var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var mr = require("npm-registry-mock")
+var path = require("path")
// config
-var pkg = __dirname + '/outdated-include-devdependencies'
-mkdirp.sync(pkg + "/cache")
+var pkg = path.resolve(__dirname, "outdated-include-devdependencies")
+var cache = path.resolve(pkg, "cache")
+mkdirp.sync(cache)
test("includes devDependencies in outdated", function (t) {
process.chdir(pkg)
mr(common.port, function (s) {
- npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
+ npm.load({cache: cache, registry: common.registry}, function () {
npm.outdated(function (er, d) {
t.equal("1.5.1", d[0][3])
s.close()
@@ -23,6 +25,6 @@ test("includes devDependencies in outdated", function (t) {
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(cache)
t.end()
})
diff --git a/test/tap/outdated-json.js b/test/tap/outdated-json.js
index 7c19561ee..b874f28e6 100644
--- a/test/tap/outdated-json.js
+++ b/test/tap/outdated-json.js
@@ -5,29 +5,29 @@ var common = require("../common-tap.js")
, mr = require("npm-registry-mock")
, path = require("path")
, osenv = require("osenv")
- , spawn = require('child_process').spawn
+ , spawn = require("child_process").spawn
, node = process.execPath
- , npmc = require.resolve('../../')
- , pkg = path.resolve(__dirname, 'outdated-new-versions')
+ , npmc = require.resolve("../../")
+ , pkg = path.resolve(__dirname, "outdated-new-versions")
, args = [ npmc
- , 'outdated'
- , '--json'
- , '--silent'
- , '--registry=' + common.registry
- , '--cache=' + pkg + '/cache'
+ , "outdated"
+ , "--json"
+ , "--silent"
+ , "--registry=" + common.registry
+ , "--cache=" + pkg + "/cache"
]
var expected = { underscore:
- { current: '1.3.3'
- , wanted: '1.3.3'
- , latest: '1.5.1'
- , location: 'node_modules' + path.sep + 'underscore'
+ { current: "1.3.3"
+ , wanted: "1.3.3"
+ , latest: "1.5.1"
+ , location: "node_modules" + path.sep + "underscore"
}
, request:
- { current: '0.9.5'
- , wanted: '0.9.5'
- , latest: '2.27.0'
- , location: 'node_modules' + path.sep + 'request'
+ { current: "0.9.5"
+ , wanted: "0.9.5"
+ , latest: "2.27.0"
+ , location: "node_modules" + path.sep + "request"
}
}
@@ -38,18 +38,19 @@ test("it should log json data", function (t) {
mr(common.port, function (s) {
npm.load({
cache: pkg + "/cache",
- loglevel: 'silent',
+ loglevel: "silent",
registry: common.registry }
, function () {
npm.install(".", function (err) {
+ t.ifError(err, "error should not exist")
var child = spawn(node, args)
- , out = ''
+ , out = ""
child.stdout
- .on('data', function (buf) {
+ .on("data", function (buf) {
out += buf.toString()
})
.pipe(process.stdout)
- child.on('exit', function () {
+ child.on("exit", function () {
out = JSON.parse(out)
t.deepEqual(out, expected)
s.close()
diff --git a/test/tap/outdated-new-versions.js b/test/tap/outdated-new-versions.js
index 177973617..cb7eaa473 100644
--- a/test/tap/outdated-new-versions.js
+++ b/test/tap/outdated-new-versions.js
@@ -3,11 +3,13 @@ var test = require("tap").test
var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
+var path = require("path")
var mr = require("npm-registry-mock")
-var pkg = __dirname + "/outdated-new-versions"
-mkdirp.sync(pkg + "/cache")
+var pkg = path.resolve(__dirname, "outdated-new-versions")
+var cache = path.resolve(pkg, "cache")
+mkdirp.sync(cache)
test("dicovers new versions in outdated", function (t) {
@@ -15,7 +17,7 @@ test("dicovers new versions in outdated", function (t) {
t.plan(2)
mr(common.port, function (s) {
- npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
+ npm.load({cache: cache, registry: common.registry}, function () {
npm.outdated(function (er, d) {
for (var i = 0; i < d.length; i++) {
if (d[i][1] === "underscore")
@@ -31,6 +33,6 @@ test("dicovers new versions in outdated", function (t) {
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(cache)
t.end()
})
diff --git a/test/tap/outdated.js b/test/tap/outdated.js
index dddec77ea..9f4b14d1f 100644
--- a/test/tap/outdated.js
+++ b/test/tap/outdated.js
@@ -1,14 +1,14 @@
var common = require("../common-tap.js")
-var fs = require("fs")
var test = require("tap").test
var rimraf = require("rimraf")
var npm = require("../../")
+var path = require("path")
var mr = require("npm-registry-mock")
// config
-var pkg = __dirname + '/outdated'
-
-var path = require("path")
+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()
@@ -33,13 +33,15 @@ test("it should not throw", function (t) {
}
mr(common.port, function (s) {
npm.load({
- cache: pkg + "/cache",
- loglevel: 'silent',
+ cache: "cache",
+ loglevel: "silent",
parseable: true,
registry: common.registry }
, function () {
npm.install(".", function (err) {
+ t.ifError(err, "install success")
npm.outdated(function (er, d) {
+ t.ifError(er, "outdated success")
console.log = originalLog
t.same(output, expOut)
t.same(d, expData)
@@ -57,6 +59,6 @@ test("cleanup", function (t) {
})
function cleanup () {
- rimraf.sync(pkg + "/node_modules")
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(nodeModules)
+ rimraf.sync(cache)
}
diff --git a/test/tap/peer-deps-invalid.js b/test/tap/peer-deps-invalid.js
index c28736550..098f3ccb1 100644
--- a/test/tap/peer-deps-invalid.js
+++ b/test/tap/peer-deps-invalid.js
@@ -1,18 +1,20 @@
-var common = require('../common-tap.js')
+var common = require("../common-tap")
var fs = require("fs")
var path = require("path")
var test = require("tap").test
var rimraf = require("rimraf")
var npm = require("../../")
var mr = require("npm-registry-mock")
-var pkg = __dirname + "/peer-deps-invalid"
+var pkg = path.resolve(__dirname, "peer-deps-invalid")
+var cache = path.resolve(pkg, "cache")
+var nodeModules = path.resolve(pkg, "node_modules")
var okFile = fs.readFileSync(path.join(pkg, "file-ok.js"), "utf8")
var failFile = fs.readFileSync(path.join(pkg, "file-fail.js"), "utf8")
test("installing dependencies that have conflicting peerDependencies", function (t) {
- rimraf.sync(pkg + "/node_modules")
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(nodeModules)
+ rimraf.sync(cache)
process.chdir(pkg)
var customMocks = {
@@ -23,7 +25,7 @@ test("installing dependencies that have conflicting peerDependencies", function
}
mr({port: common.port, mocks: customMocks}, function (s) { // create mock registry.
npm.load({
- cache: pkg + "/cache",
+ cache: cache,
registry: common.registry
}, function () {
npm.commands.install([], function (err) {
@@ -40,7 +42,7 @@ test("installing dependencies that have conflicting peerDependencies", function
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/node_modules")
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(nodeModules)
+ rimraf.sync(cache)
t.end()
})
diff --git a/test/tap/peer-deps-without-package-json.js b/test/tap/peer-deps-without-package-json.js
index ce01be4d0..eb000782f 100644
--- a/test/tap/peer-deps-without-package-json.js
+++ b/test/tap/peer-deps-without-package-json.js
@@ -1,37 +1,39 @@
-var common = require('../common-tap.js')
+var common = require("../common-tap")
var fs = require("fs")
var path = require("path")
var test = require("tap").test
var rimraf = require("rimraf")
var npm = require("../../")
var mr = require("npm-registry-mock")
-var pkg = __dirname + "/peer-deps-without-package-json"
+var pkg = path.resolve(__dirname, "peer-deps-without-package-json")
+var cache = path.resolve(pkg, "cache")
+var nodeModules = path.resolve(pkg, "node_modules")
var js = fs.readFileSync(path.join(pkg, "file-js.js"), "utf8")
test("installing a peerDependencies-using package without a package.json present (GH-3049)", function (t) {
- rimraf.sync(pkg + "/node_modules")
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(nodeModules)
+ rimraf.sync(cache)
- fs.mkdirSync(pkg + "/node_modules")
+ fs.mkdirSync(nodeModules)
process.chdir(pkg)
var customMocks = {
"get": {
- "/ok.js": [200, js],
+ "/ok.js": [200, js]
}
}
mr({port: common.port, mocks: customMocks}, function (s) { // create mock registry.
npm.load({
registry: common.registry,
- cache: pkg + "/cache"
+ cache: cache
}, function () {
npm.install(common.registry + "/ok.js", function (err) {
if (err) {
t.fail(err)
} else {
- t.ok(fs.existsSync(pkg + "/node_modules/npm-test-peer-deps-file"))
- t.ok(fs.existsSync(pkg + "/node_modules/underscore"))
+ t.ok(fs.existsSync(path.join(nodeModules, "/npm-test-peer-deps-file")))
+ t.ok(fs.existsSync(path.join(nodeModules, "/underscore")))
}
t.end()
s.close() // shutdown mock registry.
@@ -41,7 +43,7 @@ test("installing a peerDependencies-using package without a package.json present
})
test("cleanup", function (t) {
- rimraf.sync(pkg + "/node_modules")
- rimraf.sync(pkg + "/cache")
+ rimraf.sync(nodeModules)
+ rimraf.sync(cache)
t.end()
})
diff --git a/test/tap/peer-deps.js b/test/tap/peer-deps.js
index 097a92179..0368f5c7c 100644
--- a/test/tap/peer-deps.js
+++ b/test/tap/peer-deps.js
@@ -46,7 +46,7 @@ function setup (cb) {
cleanup()
process.chdir(pkg)
- var opts = { cache: path.resolve(pkg, "cache"), registry: common.registry};
+ var opts = { cache: path.resolve(pkg, "cache"), registry: common.registry}
npm.load(opts, cb)
}
diff --git a/test/tap/prune.js b/test/tap/prune.js
index a303d840c..671fccee0 100644
--- a/test/tap/prune.js
+++ b/test/tap/prune.js
@@ -7,10 +7,12 @@ var mr = require("npm-registry-mock")
var common = require("../common-tap.js")
var spawn = require("child_process").spawn
var env = process.env
+var path = require("path")
+
process.env.npm_config_depth = "Infinity"
-var pkg = __dirname + "/prune"
-var cache = pkg + "/cache"
+var pkg = path.resolve(__dirname, "prune")
+var cache = path.resolve(pkg, "cache")
var server
diff --git a/test/tap/publish-config.js b/test/tap/publish-config.js
index e1ad9c7da..c19bc69c5 100644
--- a/test/tap/publish-config.js
+++ b/test/tap/publish-config.js
@@ -1,11 +1,11 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var fs = require('fs')
-var osenv = require('osenv')
-var pkg = process.env.npm_config_tmp || '/tmp'
-pkg += '/npm-test-publish-config'
+var common = require("../common-tap.js")
+var test = require("tap").test
+var fs = require("fs")
+var osenv = require("osenv")
+var pkg = process.env.npm_config_tmp || "/tmp"
+pkg += "/npm-test-publish-config"
-require('mkdirp').sync(pkg)
+require("mkdirp").sync(pkg)
fs.writeFileSync(pkg + "/package.json", JSON.stringify({
name: "npm-test-publish-config",
@@ -19,21 +19,19 @@ fs.writeFileSync(pkg + "/fixture_npmrc",
"//localhost:1337/:_password = " + new Buffer("feast").toString("base64") + "\n" +
"registry = http://localhost:1337/")
-var spawn = require('child_process').spawn
-var npm = require.resolve('../../bin/npm-cli.js')
-var node = process.execPath
-
test(function (t) {
var child
- require('http').createServer(function (req, res) {
- t.pass('got request on the fakey fake registry')
+ require("http").createServer(function (req, res) {
+ t.pass("got request on the fakey fake registry")
t.end()
this.close()
res.statusCode = 500
- res.end('{"error":"sshhh. naptime nao. \\^O^/ <(YAWWWWN!)"}')
+ res.end(JSON.stringify({
+ error: "sshhh. naptime nao. \\^O^/ <(YAWWWWN!)"
+ }))
child.kill()
}).listen(common.port, function () {
- t.pass('server is listening')
+ t.pass("server is listening")
// don't much care about listening to the child's results
// just wanna make sure it hits the server we just set up.
@@ -42,18 +40,20 @@ test(function (t) {
// itself functions normally.
//
// Make sure that we don't sit around waiting for lock files
-
child = common.npm(["publish", "--userconfig=" + pkg + "/fixture_npmrc"], {
cwd: pkg,
stdio: "inherit",
env: {
- npm_config_cache_lock_stale: 1000,
- npm_config_cache_lock_wait: 1000,
+ "npm_config_cache_lock_stale": 1000,
+ "npm_config_cache_lock_wait": 1000,
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH,
USERPROFILE: osenv.home()
}
- }, function(err, code, stdout, stderr) { })
+ }, function(err, code) {
+ t.ifError(err, "publish command finished successfully")
+ t.notOk(code, "npm install exited with code 0")
+ })
})
})
diff --git a/test/tap/pwd-prefix.js b/test/tap/pwd-prefix.js
index e041552e7..66a30d552 100644
--- a/test/tap/pwd-prefix.js
+++ b/test/tap/pwd-prefix.js
@@ -16,7 +16,7 @@ commands.forEach(function (cmd) {
test(cmd + " in root", function (t) {
common.npm([cmd], {cwd: root}, function(er, code, so, se) {
if (er) throw er
- t.equal(code, 0)
+ t.notOk(code, "npm " + cmd + " exited with code 0")
stdout = so
stderr = se
t.end()
@@ -26,7 +26,7 @@ commands.forEach(function (cmd) {
test(cmd + " in lib", function (t) {
common.npm([cmd], {cwd: lib}, function(er, code, so, se) {
if (er) throw er
- t.equal(code, 0)
+ t.notOk(code, "npm " + cmd + " exited with code 0")
t.equal(so, stdout)
t.equal(se, stderr)
t.end()
diff --git a/test/tap/referer.js b/test/tap/referer.js
index bc32d5d67..c1b173d97 100644
--- a/test/tap/referer.js
+++ b/test/tap/referer.js
@@ -1,10 +1,9 @@
var common = require("../common-tap.js")
var test = require("tap").test
var http = require("http")
-var server
test("should send referer http header", function (t) {
- var server = http.createServer(function (q, s) {
+ http.createServer(function (q, s) {
t.equal(q.headers.referer, "install foo")
s.statusCode = 404
s.end(JSON.stringify({error: "whatever"}))
@@ -12,7 +11,7 @@ test("should send referer http header", function (t) {
}).listen(common.port, function () {
var reg = "http://localhost:" + common.port
var args = [ "install", "foo", "--registry", reg ]
- common.npm(args, {}, function (er, code, so, se) {
+ common.npm(args, {}, function (er, code) {
if (er) {
throw er
}
diff --git a/test/tap/registry.js b/test/tap/registry.js
index 029d8d4dd..9dcdf8bfa 100644
--- a/test/tap/registry.js
+++ b/test/tap/registry.js
@@ -4,7 +4,6 @@
var common = require("../common-tap")
var test = require("tap").test
-var spawn = require("child_process").spawn
var npmExec = require.resolve("../../bin/npm-cli.js")
var path = require("path")
var ca = path.resolve(__dirname, "../../node_modules/npm-registry-couchapp")
@@ -39,10 +38,11 @@ function runTests () {
cwd: ca,
stdio: "inherit"
}
- common.npm(['install'], opts, function(err, code) {
+ common.npm(["install"], opts, function(err, code) {
+ if (err) { throw err }
if (code) {
return test("need install to work", function (t) {
- t.fail("install failed with: " + (code || sig))
+ t.fail("install failed with: " + code)
t.end()
})
@@ -52,13 +52,21 @@ function runTests () {
env: env,
stdio: "inherit"
}
- common.npm(['test'], opts, function(err, code) {
+ common.npm(["test"], opts, function(err, code) {
+ if (err) { throw err }
+ if (code) {
+ return test("need test to work", function(t) {
+ t.fail("test failed with: " + code)
+ t.end()
+ })
+ }
opts = {
cwd: ca,
env: env,
stdio: "inherit"
}
- common.npm(['prune', '--production'], opts, function(err, code) {
+ common.npm(["prune", "--production"], opts, function(err, code) {
+ if (err) { throw err }
process.exit(code || 0)
})
})
diff --git a/test/tap/run-script.js b/test/tap/run-script.js
index a308b5ffe..4ae43c36b 100644
--- a/test/tap/run-script.js
+++ b/test/tap/run-script.js
@@ -1,14 +1,11 @@
-var common = require('../common-tap')
- , test = require('tap').test
- , path = require('path')
- , spawn = require('child_process').spawn
- , rimraf = require('rimraf')
- , mkdirp = require('mkdirp')
- , pkg = __dirname + '/run-script'
- , cache = pkg + '/cache'
- , tmp = pkg + '/tmp'
- , node = process.execPath
- , npm = path.resolve(__dirname, '../../cli.js')
+var common = require("../common-tap")
+ , test = require("tap").test
+ , path = require("path")
+ , rimraf = require("rimraf")
+ , mkdirp = require("mkdirp")
+ , pkg = path.resolve(__dirname, "run-script")
+ , cache = path.resolve(pkg, "cache")
+ , tmp = path.resolve(pkg, "tmp")
, opts = { cwd: pkg }
function testOutput (t, command, er, code, stdout, stderr) {
@@ -16,47 +13,47 @@ function testOutput (t, command, er, code, stdout, stderr) {
throw er
if (stderr)
- throw new Error('npm ' + command + ' stderr: ' + stderr.toString())
+ throw new Error("npm " + command + " stderr: " + stderr.toString())
- stdout = stdout.trim().split('\n')
+ stdout = stdout.trim().split("\n")
stdout = stdout[stdout.length - 1]
t.equal(stdout, command)
t.end()
}
function cleanup () {
- rimraf.sync(pkg + '/cache')
- rimraf.sync(pkg + '/tmp')
+ rimraf.sync(cache)
+ rimraf.sync(tmp)
}
-test('setup', function (t) {
+test("setup", function (t) {
cleanup()
- mkdirp.sync(pkg + '/cache')
- mkdirp.sync(pkg + '/tmp')
+ mkdirp.sync(cache)
+ mkdirp.sync(tmp)
t.end()
})
-test('npm run-script', function (t) {
- common.npm(['run-script', 'start'], opts, testOutput.bind(null, t, "start"))
+test("npm run-script", function (t) {
+ common.npm(["run-script", "start"], opts, testOutput.bind(null, t, "start"))
})
-test('npm run-script with args', function (t) {
+test("npm run-script with args", function (t) {
common.npm(["run-script", "start", "--", "stop"], opts, testOutput.bind(null, t, "stop"))
})
-test('npm run-script with args that contain spaces', function(t) {
+test("npm run-script with args that contain spaces", function(t) {
common.npm(["run-script", "start", "--", "hello world"], opts, testOutput.bind(null, t, "hello world"))
})
-test('npm run-script with args that contain single quotes', function(t) {
+test("npm run-script with args that contain single quotes", function(t) {
common.npm(["run-script", "start", "--", "they're awesome"], opts, testOutput.bind(null, t, "they're awesome"))
})
-test('npm run-script with args that contain double quotes', function(t) {
+test("npm run-script with args that contain double quotes", function(t) {
common.npm(["run-script", "start", "--", "what's \"up\"?"], opts, testOutput.bind(null, t, "what's \"up\"?"))
})
-test('cleanup', function (t) {
+test("cleanup", function (t) {
cleanup()
t.end()
})
diff --git a/test/tap/scripts-whitespace-windows.js b/test/tap/scripts-whitespace-windows.js
index c3d5e5602..c459f17b4 100644
--- a/test/tap/scripts-whitespace-windows.js
+++ b/test/tap/scripts-whitespace-windows.js
@@ -1,57 +1,57 @@
-var test = require('tap').test
-var path = require('path')
-var npm = path.resolve(__dirname, '../../cli.js')
-var pkg = __dirname + '/scripts-whitespace-windows'
-var tmp = pkg + '/tmp'
-var cache = pkg + '/cache'
-var modules = pkg + '/node_modules'
-var dep = pkg + '/dep'
+var test = require("tap").test
+var path = require("path")
+var npm = path.resolve(__dirname, "../../cli.js")
+var pkg = path.resolve(__dirname, "scripts-whitespace-windows")
+var tmp = path.resolve(pkg, "tmp")
+var cache = path.resolve(pkg, "cache")
+var modules = path.resolve(pkg, "node_modules")
+var dep = path.resolve(pkg, "dep")
-var mkdirp = require('mkdirp')
-var rimraf = require('rimraf')
+var mkdirp = require("mkdirp")
+var rimraf = require("rimraf")
var node = process.execPath
-var spawn = require('child_process').spawn
+var spawn = require("child_process").spawn
-test('setup', function (t) {
+test("setup", function (t) {
mkdirp.sync(cache)
mkdirp.sync(tmp)
rimraf.sync(modules)
var env = {
- npm_config_cache: cache,
- npm_config_tmp: tmp,
- npm_config_prefix: pkg,
- npm_config_global: 'false'
+ "npm_config_cache": cache,
+ "npm_config_tmp": tmp,
+ "npm_config_prefix": pkg,
+ "npm_config_global": "false"
}
- var child = spawn(node, [npm, 'i', dep], {
+ var child = spawn(node, [npm, "i", dep], {
cwd: pkg,
env: env
})
- child.stdout.setEncoding('utf8')
- child.stderr.on('data', function(chunk) {
- t.fail('got stderr data: ' + JSON.stringify('' + chunk))
+ child.stdout.setEncoding("utf8")
+ child.stderr.on("data", function(chunk) {
+ t.fail("got stderr data: " + JSON.stringify("" + chunk))
})
- child.on('close', function () {
+ child.on("close", function () {
t.end()
})
})
-test('test', function (t) {
+test("test", function (t) {
- var child = spawn(node, [npm, 'run', 'foo'], {
+ var child = spawn(node, [npm, "run", "foo"], {
cwd: pkg,
env: process.env
})
- child.stdout.setEncoding('utf8')
- child.stderr.on('data', function(chunk) {
- t.fail('got stderr data: ' + JSON.stringify('' + chunk))
+ child.stdout.setEncoding("utf8")
+ child.stderr.on("data", function(chunk) {
+ t.fail("got stderr data: " + JSON.stringify("" + chunk))
})
- child.stdout.on('data', ondata)
- child.on('close', onend)
- var c = ''
+ child.stdout.on("data", ondata)
+ child.on("close", onend)
+ var c = ""
function ondata (chunk) {
c += chunk
}
@@ -63,7 +63,7 @@ test('test', function (t) {
}
})
-test('cleanup', function (t) {
+test("cleanup", function (t) {
rimraf.sync(cache)
rimraf.sync(tmp)
rimraf.sync(modules)
diff --git a/test/tap/semver-doc.js b/test/tap/semver-doc.js
index 5133f4659..de7dcd0dc 100644
--- a/test/tap/semver-doc.js
+++ b/test/tap/semver-doc.js
@@ -5,7 +5,7 @@ test("semver doc is up to date", function(t) {
var moddoc = path.join(__dirname, "../../node_modules/semver/README.md")
var mydoc = path.join(__dirname, "../../doc/misc/semver.md")
var fs = require("fs")
- var mod = fs.readFileSync(moddoc, "utf8").replace(/semver\(1\)/, 'semver(7)')
+ var mod = fs.readFileSync(moddoc, "utf8").replace(/semver\(1\)/, "semver(7)")
var my = fs.readFileSync(mydoc, "utf8")
t.equal(my, mod)
t.end()
diff --git a/test/tap/semver-tag.js b/test/tap/semver-tag.js
index 7633e5542..03dcdf85b 100644
--- a/test/tap/semver-tag.js
+++ b/test/tap/semver-tag.js
@@ -5,7 +5,7 @@ var test = require("tap").test
test("try to tag with semver range as tag name", function (t) {
var cmd = ["tag", "zzzz@1.2.3", "v2.x", "--registry=http://localhost"]
common.npm(cmd, {
- stdio: "pipe",
+ stdio: "pipe"
}, function (er, code, so, se) {
if (er) throw er
t.similar(se, /Tag name must not be a valid SemVer range: v2.x\n/)
diff --git a/test/tap/shrinkwrap-empty-deps.js b/test/tap/shrinkwrap-empty-deps.js
index 9ec8e71e0..6be67af74 100644
--- a/test/tap/shrinkwrap-empty-deps.js
+++ b/test/tap/shrinkwrap-empty-deps.js
@@ -6,7 +6,8 @@ var test = require("tap").test
, fs = require("fs")
, osenv = require("osenv")
, rimraf = require("rimraf")
- , pkg = __dirname + "/shrinkwrap-empty-deps"
+ , pkg = path.resolve(__dirname, "shrinkwrap-empty-deps")
+ , cache = path.resolve(pkg, "cache")
test("returns a list of removed items", function (t) {
var desiredResultsPath = path.resolve(pkg, "npm-shrinkwrap.json")
@@ -36,7 +37,7 @@ test("returns a list of removed items", function (t) {
function setup (cb) {
cleanup()
process.chdir(pkg)
- npm.load({cache: pkg + "/cache", registry: common.registry}, function () {
+ npm.load({cache: cache, registry: common.registry}, function () {
cb()
})
}
diff --git a/test/tap/sorted-package-json.js b/test/tap/sorted-package-json.js
index 41c90855a..1dec1d2ae 100644
--- a/test/tap/sorted-package-json.js
+++ b/test/tap/sorted-package-json.js
@@ -30,11 +30,11 @@ test("sorting dependencies", function (t) {
var child = spawn(node, [npm, "install", "--save", "underscore@1.3.3"], {
cwd: pkg,
env: {
- npm_config_registry: common.registry,
- npm_config_cache: cache,
- npm_config_tmp: tmp,
- npm_config_prefix: pkg,
- npm_config_global: "false",
+ "npm_config_registry": common.registry,
+ "npm_config_cache": cache,
+ "npm_config_tmp": tmp,
+ "npm_config_prefix": pkg,
+ "npm_config_global": "false",
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH
@@ -42,6 +42,7 @@ test("sorting dependencies", function (t) {
})
child.on("close", function (code) {
+ t.equal(code, 0, "npm install exited with code")
var result = fs.readFileSync(packageJson).toString()
, resultAsJson = JSON.parse(result)
@@ -83,7 +84,7 @@ function setup() {
"underscore": "^1.3.3",
"request": "^0.9.0"
}
- }, null, 2), 'utf8')
+ }, null, 2), "utf8")
}
function cleanup() {
diff --git a/test/tap/spawn-enoent.js b/test/tap/spawn-enoent.js
index 7ea9dab56..20fed21bc 100644
--- a/test/tap/spawn-enoent.js
+++ b/test/tap/spawn-enoent.js
@@ -26,7 +26,7 @@ test("enoent script", function (t) {
env: {
PATH: process.env.PATH,
Path: process.env.Path,
- npm_config_loglevel: "warn"
+ "npm_config_loglevel": "warn"
}
}, function (er, code, sout, serr) {
t.similar(serr, /npm ERR! Failed at the x@1\.2\.3 start script\./)
diff --git a/test/tap/startstop.js b/test/tap/startstop.js
index 01fe29876..334551ed2 100644
--- a/test/tap/startstop.js
+++ b/test/tap/startstop.js
@@ -1,21 +1,18 @@
-var common = require('../common-tap')
- , test = require('tap').test
- , path = require('path')
- , spawn = require('child_process').spawn
- , rimraf = require('rimraf')
- , mkdirp = require('mkdirp')
- , pkg = __dirname + '/startstop'
- , cache = pkg + '/cache'
- , tmp = pkg + '/tmp'
- , node = process.execPath
- , npm = path.resolve(__dirname, '../../cli.js')
+var common = require("../common-tap")
+ , test = require("tap").test
+ , path = require("path")
+ , rimraf = require("rimraf")
+ , mkdirp = require("mkdirp")
+ , pkg = path.resolve(__dirname, "startstop")
+ , cache = path.resolve(pkg, "cache")
+ , tmp = path.resolve(pkg, "tmp")
, opts = { cwd: pkg }
function testOutput (t, command, er, code, stdout, stderr) {
- t.equal(code, 0)
+ t.notOk(code, "npm " + command + " exited with code 0")
if (stderr)
- throw new Error('npm ' + command + ' stderr: ' + stderr.toString())
+ throw new Error("npm " + command + " stderr: " + stderr.toString())
stdout = stdout.trim().split(/\n|\r/)
stdout = stdout[stdout.length - 1]
@@ -24,40 +21,40 @@ function testOutput (t, command, er, code, stdout, stderr) {
}
function cleanup () {
- rimraf.sync(pkg + '/cache')
- rimraf.sync(pkg + '/tmp')
+ rimraf.sync(cache)
+ rimraf.sync(tmp)
}
-test('setup', function (t) {
+test("setup", function (t) {
cleanup()
- mkdirp.sync(pkg + '/cache')
- mkdirp.sync(pkg + '/tmp')
+ mkdirp.sync(cache)
+ mkdirp.sync(tmp)
t.end()
})
-test('npm start', function (t) {
- common.npm(['start'], opts, testOutput.bind(null, t, "start"))
+test("npm start", function (t) {
+ common.npm(["start"], opts, testOutput.bind(null, t, "start"))
})
-test('npm stop', function (t) {
- common.npm(['stop'], opts, testOutput.bind(null, t, "stop"))
+test("npm stop", function (t) {
+ common.npm(["stop"], opts, testOutput.bind(null, t, "stop"))
})
-test('npm restart', function (t) {
- common.npm(['restart'], opts, function (er, c, stdout, stderr) {
+test("npm restart", function (t) {
+ common.npm(["restart"], opts, function (er, c, stdout) {
if (er)
throw er
- var output = stdout.split('\n').filter(function (val) {
+ var output = stdout.split("\n").filter(function (val) {
return val.match(/^s/)
})
- t.same(output.sort(), ['start', 'stop'].sort())
+ t.same(output.sort(), ["start", "stop"].sort())
t.end()
})
})
-test('cleanup', function (t) {
+test("cleanup", function (t) {
cleanup()
t.end()
})
diff --git a/test/tap/test-run-ls.js b/test/tap/test-run-ls.js
index 4c869e5e2..252c6e8f9 100644
--- a/test/tap/test-run-ls.js
+++ b/test/tap/test-run-ls.js
@@ -6,7 +6,7 @@ var testscript = require("../../package.json").scripts.test
var tsregexp = testscript.replace(/([\[\.\*\]])/g, "\\$1")
test("default", function (t) {
- common.npm(["run"], { cwd: cwd }, function (er, code, so, se) {
+ common.npm(["run"], { cwd: cwd }, function (er, code, so) {
if (er) throw er
t.notOk(code)
t.similar(so, new RegExp("\\n test\\n " + tsregexp + "\\n"))
@@ -15,7 +15,7 @@ test("default", function (t) {
})
test("parseable", function (t) {
- common.npm(["run", "-p"], { cwd: cwd }, function (er, code, so, se) {
+ common.npm(["run", "-p"], { cwd: cwd }, function (er, code, so) {
if (er) throw er
t.notOk(code)
t.similar(so, new RegExp("\\ntest:" + tsregexp + "\\n"))
@@ -24,7 +24,7 @@ test("parseable", function (t) {
})
test("parseable", function (t) {
- common.npm(["run", "--json"], { cwd: cwd }, function (er, code, so, se) {
+ common.npm(["run", "--json"], { cwd: cwd }, function (er, code, so) {
if (er) throw er
t.notOk(code)
t.equal(JSON.parse(so).test, testscript)
diff --git a/test/tap/uninstall-package.js b/test/tap/uninstall-package.js
index 068270125..a0ba4c6c1 100644
--- a/test/tap/uninstall-package.js
+++ b/test/tap/uninstall-package.js
@@ -3,7 +3,8 @@ var test = require("tap").test
, rimraf = require("rimraf")
, mr = require("npm-registry-mock")
, common = require("../common-tap.js")
- , pkg = __dirname + "/uninstall-package"
+ , path = require("path")
+ , pkg = path.join(__dirname, "uninstall-package")
test("returns a list of removed items", function (t) {
t.plan(1)
diff --git a/test/tap/unpack-foreign-tarball.js b/test/tap/unpack-foreign-tarball.js
index a03f9b17f..d2e2e73c9 100644
--- a/test/tap/unpack-foreign-tarball.js
+++ b/test/tap/unpack-foreign-tarball.js
@@ -12,8 +12,8 @@ var tmp = path.resolve(dir, "tmp")
var pkg = path.resolve(nm, "npm-test-gitignore")
var env = {
- npm_config_cache: cache,
- npm_config_tmp: tmp
+ "npm_config_cache": cache,
+ "npm_config_tmp": tmp
}
var conf = {
@@ -22,36 +22,39 @@ var conf = {
stdio: [ "pipe", "pipe", 2 ]
}
+function verify (t, files, err, code) {
+ if (code) {
+ t.fail("exited with failure: " + code)
+ return t.end()
+ }
+ var actual = fs.readdirSync(pkg).sort()
+ var expect = files.concat([".npmignore", "package.json"]).sort()
+ t.same(actual, expect)
+ t.end()
+}
+
test("npmignore only", function (t) {
setup()
var file = path.resolve(dir, "npmignore.tgz")
- common.npm(["install", file], conf, function (code, stdout, stderr) {
- verify(t, code, ["foo"])
- })
+ common.npm(["install", file], conf, verify.bind(null, t, ["foo"]))
})
test("gitignore only", function (t) {
setup()
var file = path.resolve(dir, "gitignore.tgz")
- common.npm(["install", file], conf, function (code, stdout, stderr) {
- verify(t, code, ["foo"])
- })
+ common.npm(["install", file], conf, verify.bind(null, t, ["foo"]))
})
test("gitignore and npmignore", function (t) {
setup()
var file = path.resolve(dir, "gitignore-and-npmignore.tgz")
- common.npm(["install", file], conf, function (code, stdout, stderr) {
- verify(t, code, ["foo", "bar"])
- })
+ common.npm(["install", file], conf, verify.bind(null, t, ["foo", "bar"]))
})
test("gitignore and npmignore, not gzipped", function (t) {
setup()
var file = path.resolve(dir, "gitignore-and-npmignore.tar")
- common.npm(["install", file], conf, function (code, stdout, stderr) {
- verify(t, code, ["foo", "bar"])
- })
+ common.npm(["install", file], conf, verify.bind(null, t, ["foo", "bar"]))
})
test("clean", function (t) {
@@ -59,17 +62,6 @@ test("clean", function (t) {
t.end()
})
-function verify (t, code, files) {
- if (code) {
- t.fail("exited with failure: " + code)
- return t.end()
- }
- var actual = fs.readdirSync(pkg).sort()
- var expect = files.concat([".npmignore", "package.json"]).sort()
- t.same(actual, expect)
- t.end()
-}
-
function setup () {
clean()
mkdirp.sync(nm)
diff --git a/test/tap/update-save.js b/test/tap/update-save.js
index 6323ef851..5f871b26c 100644
--- a/test/tap/update-save.js
+++ b/test/tap/update-save.js
@@ -3,8 +3,8 @@ var test = require("tap").test
var npm = require("../../")
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
-var fs = require('fs')
-var path = require('path')
+var fs = require("fs")
+var path = require("path")
var mr = require("npm-registry-mock")
var PKG_DIR = path.resolve(__dirname, "update-save")
@@ -14,10 +14,10 @@ var MODULES_DIR = path.resolve(PKG_DIR, "node_modules")
var EXEC_OPTS = {
cwd: PKG_DIR,
- stdio: 'ignore',
+ stdio: "ignore",
env: {
- npm_config_registry: common.registry,
- npm_config_loglevel: 'verbose'
+ "npm_config_registry": common.registry,
+ "npm_config_loglevel": "verbose"
}
}
@@ -32,9 +32,9 @@ var DEFAULT_PKG = {
}
}
-var s = undefined // mock server reference
+var s // mock server reference
-test('setup', function (t) {
+test("setup", function (t) {
resetPackage()
mr(common.port, function (server) {
@@ -49,14 +49,14 @@ test('setup', function (t) {
test("update regular dependencies only", function (t) {
resetPackage()
- common.npm(['update', '--save'], EXEC_OPTS, function (err, code) {
+ common.npm(["update", "--save"], EXEC_OPTS, function (err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm update exited with code 0")
- var pkgdata = JSON.parse(fs.readFileSync(PKG, 'utf8'))
- t.deepEqual(pkgdata.dependencies, {mkdirp: '^0.3.5'}, 'only dependencies updated')
- t.deepEqual(pkgdata.devDependencies, DEFAULT_PKG.devDependencies, 'dev dependencies should be untouched')
- t.deepEqual(pkgdata.optionalDependencies, DEFAULT_PKG.optionalDependencies, 'optional dependencies should be untouched')
+ var pkgdata = JSON.parse(fs.readFileSync(PKG, "utf8"))
+ t.deepEqual(pkgdata.dependencies, {mkdirp: "^0.3.5"}, "only dependencies updated")
+ t.deepEqual(pkgdata.devDependencies, DEFAULT_PKG.devDependencies, "dev dependencies should be untouched")
+ t.deepEqual(pkgdata.optionalDependencies, DEFAULT_PKG.optionalDependencies, "optional dependencies should be untouched")
t.end()
})
})
@@ -64,14 +64,14 @@ test("update regular dependencies only", function (t) {
test("update devDependencies only", function (t) {
resetPackage()
- common.npm(['update', '--save-dev'], EXEC_OPTS, function (err, code, stdout, stderr) {
+ common.npm(["update", "--save-dev"], EXEC_OPTS, function (err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm update exited with code 0")
- var pkgdata = JSON.parse(fs.readFileSync(PKG, 'utf8'))
- t.deepEqual(pkgdata.dependencies, DEFAULT_PKG.dependencies, 'dependencies should be untouched')
- t.deepEqual(pkgdata.devDependencies, {underscore: '^1.3.3'}, 'dev dependencies should be updated')
- t.deepEqual(pkgdata.optionalDependencies, DEFAULT_PKG.optionalDependencies, 'optional dependencies should be untouched')
+ var pkgdata = JSON.parse(fs.readFileSync(PKG, "utf8"))
+ t.deepEqual(pkgdata.dependencies, DEFAULT_PKG.dependencies, "dependencies should be untouched")
+ t.deepEqual(pkgdata.devDependencies, {underscore: "^1.3.3"}, "dev dependencies should be updated")
+ t.deepEqual(pkgdata.optionalDependencies, DEFAULT_PKG.optionalDependencies, "optional dependencies should be untouched")
t.end()
})
})
@@ -83,14 +83,14 @@ test("update optionalDependencies only", function (t) {
}
})
- common.npm(['update', '--save-optional'], EXEC_OPTS, function (err, code) {
+ common.npm(["update", "--save-optional"], EXEC_OPTS, function (err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm update exited with code 0")
- var pkgdata = JSON.parse(fs.readFileSync(PKG, 'utf8'))
- t.deepEqual(pkgdata.dependencies, DEFAULT_PKG.dependencies, 'dependencies should be untouched')
- t.deepEqual(pkgdata.devDependencies, DEFAULT_PKG.devDependencies, 'dev dependencies should be untouched')
- t.deepEqual(pkgdata.optionalDependencies, {underscore: '^1.3.3'}, 'optional dependencies should be updated')
+ var pkgdata = JSON.parse(fs.readFileSync(PKG, "utf8"))
+ t.deepEqual(pkgdata.dependencies, DEFAULT_PKG.dependencies, "dependencies should be untouched")
+ t.deepEqual(pkgdata.devDependencies, DEFAULT_PKG.devDependencies, "dev dependencies should be untouched")
+ t.deepEqual(pkgdata.optionalDependencies, {underscore: "^1.3.3"}, "optional dependencies should be updated")
t.end()
})
})
@@ -102,14 +102,14 @@ test("optionalDependencies are merged into dependencies during --save", function
}
})
- common.npm(['update', '--save'], EXEC_OPTS, function (err, code) {
+ common.npm(["update", "--save"], EXEC_OPTS, function (err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm update exited with code 0")
- var pkgdata = JSON.parse(fs.readFileSync(PKG, 'utf8'))
- t.deepEqual(pkgdata.dependencies, {mkdirp: '^0.3.5'}, 'dependencies should not include optional dependencies')
- t.deepEqual(pkgdata.devDependencies, pkg.devDependencies, 'dev dependencies should be untouched')
- t.deepEqual(pkgdata.optionalDependencies, pkg.optionalDependencies, 'optional dependencies should be untouched')
+ var pkgdata = JSON.parse(fs.readFileSync(PKG, "utf8"))
+ t.deepEqual(pkgdata.dependencies, {mkdirp: "^0.3.5"}, "dependencies should not include optional dependencies")
+ t.deepEqual(pkgdata.devDependencies, pkg.devDependencies, "dev dependencies should be untouched")
+ t.deepEqual(pkgdata.optionalDependencies, pkg.optionalDependencies, "optional dependencies should be untouched")
t.end()
})
})
@@ -117,16 +117,16 @@ test("optionalDependencies are merged into dependencies during --save", function
test("semver prefix is replaced with configured save-prefix", function (t) {
resetPackage()
- common.npm(['update', '--save', '--save-prefix', '~'], EXEC_OPTS, function (err, code) {
+ common.npm(["update", "--save", "--save-prefix", "~"], EXEC_OPTS, function (err, code) {
t.ifError(err)
- t.equal(code, 0)
+ t.notOk(code, "npm update exited with code 0")
- var pkgdata = JSON.parse(fs.readFileSync(PKG, 'utf8'))
+ var pkgdata = JSON.parse(fs.readFileSync(PKG, "utf8"))
t.deepEqual(pkgdata.dependencies, {
- mkdirp: '~0.3.5'
- }, 'dependencies should be updated')
- t.deepEqual(pkgdata.devDependencies, DEFAULT_PKG.devDependencies, 'dev dependencies should be untouched')
- t.deepEqual(pkgdata.optionalDependencies, DEFAULT_PKG.optionalDependencies, 'optional dependencies should be updated')
+ mkdirp: "~0.3.5"
+ }, "dependencies should be updated")
+ t.deepEqual(pkgdata.devDependencies, DEFAULT_PKG.devDependencies, "dev dependencies should be untouched")
+ t.deepEqual(pkgdata.optionalDependencies, DEFAULT_PKG.optionalDependencies, "optional dependencies should be updated")
t.end()
})
})
@@ -137,8 +137,8 @@ function resetPackage(extendWith) {
mkdirp.sync(CACHE_DIR)
var pkg = clone(DEFAULT_PKG)
extend(pkg, extendWith)
- for (key in extend) { pkg[key] = extend[key]}
- fs.writeFileSync(PKG, JSON.stringify(pkg, null, 2), 'ascii')
+ for (var key in extend) { pkg[key] = extend[key]}
+ fs.writeFileSync(PKG, JSON.stringify(pkg, null, 2), "ascii")
return pkg
}
@@ -155,6 +155,6 @@ function clone(a) {
}
function extend(a, b) {
- for (key in b) { a[key] = b[key]}
+ for (var key in b) { a[key] = b[key]}
return a
}
diff --git a/test/tap/url-dependencies.js b/test/tap/url-dependencies.js
index 8058637de..77b39723c 100644
--- a/test/tap/url-dependencies.js
+++ b/test/tap/url-dependencies.js
@@ -3,9 +3,6 @@ var rimraf = require("rimraf")
var path = require("path")
var osenv = require("osenv")
var mr = require("npm-registry-mock")
-var spawn = require("child_process").spawn
-var npm = require.resolve("../../bin/npm-cli.js")
-var node = process.execPath
var pkg = path.resolve(__dirname, "url-dependencies")
var common = require("../common-tap")
@@ -18,7 +15,7 @@ var mockRoutes = {
test("url-dependencies: download first time", function(t) {
cleanup()
- performInstall(function(output){
+ performInstall(t, function(output){
if (!tarballWasFetched(output)){
t.fail("Tarball was not fetched")
} else {
@@ -31,8 +28,8 @@ test("url-dependencies: download first time", function(t) {
test("url-dependencies: do not download subsequent times", function(t) {
cleanup()
- performInstall(function(){
- performInstall(function(output){
+ performInstall(t, function(){
+ performInstall(t, function(output){
if (tarballWasFetched(output)){
t.fail("Tarball was fetched second time around")
} else {
@@ -47,7 +44,7 @@ function tarballWasFetched(output){
return output.indexOf("http fetch GET " + common.registry + "/underscore/-/underscore-1.3.1.tgz") > -1
}
-function performInstall (cb) {
+function performInstall (t, cb) {
mr({port: common.port, mocks: mockRoutes}, function(s){
var opts = {
cwd : pkg,
@@ -62,8 +59,10 @@ function performInstall (cb) {
}
}
common.npm(["install"], opts, function(err, code, stdout, stderr) {
- s.close();
- cb(stderr);
+ t.ifError(err, "install success")
+ t.notOk(code, "npm install exited with code 0")
+ s.close()
+ cb(stderr)
})
})
}
diff --git a/test/tap/version-no-tags.js b/test/tap/version-no-tags.js
index e731c3154..45a322752 100644
--- a/test/tap/version-no-tags.js
+++ b/test/tap/version-no-tags.js
@@ -1,49 +1,47 @@
-var common = require('../common-tap.js')
-var test = require('tap').test
-var npm = require('../../')
-var npmc = require.resolve('../../')
-var osenv = require('osenv')
-var path = require('path')
-var fs = require('fs')
-var rimraf = require('rimraf')
-var mkdirp = require('mkdirp')
-var which = require('which')
-var util = require('util')
-var spawn = require('child_process').spawn
-var args = [ npmc
- , 'version'
- , 'patch'
- , '--no-git-tag-version'
- ]
-var pkg = __dirname + '/version-no-tags'
+var common = require("../common-tap.js")
+var test = require("tap").test
+var npm = require("../../")
+var osenv = require("osenv")
+var path = require("path")
+var fs = require("fs")
+var rimraf = require("rimraf")
+var mkdirp = require("mkdirp")
+var which = require("which")
+var spawn = require("child_process").spawn
+
+var pkg = path.resolve(__dirname, "version-no-tags")
+var cache = path.resolve(pkg, "cache")
test("npm version <semver> without git tag", function (t) {
setup()
- npm.load({ cache: pkg + '/cache', registry: common.registry}, function () {
- which('git', function(err, git) {
+ npm.load({ cache: cache, registry: common.registry}, function () {
+ which("git", function(err, git) {
+ t.ifError(err, "git found on system")
function tagExists(tag, _cb) {
- var child = spawn(git, ['tag', '-l', tag])
- var out = ''
- child.stdout.on('data', function(d) {
- out += data.toString()
+ var child1 = spawn(git, ["tag", "-l", tag])
+ var out = ""
+ child1.stdout.on("data", function(d) {
+ out += d.toString()
})
- child.on('exit', function() {
+ child1.on("exit", function() {
return _cb(null, Boolean(~out.indexOf(tag)))
})
}
- var child = spawn(git, ['init'])
- child.stdout.pipe(process.stdout)
- child.on('exit', function() {
- npm.config.set('git-tag-version', false)
- npm.commands.version(['patch'], function(err) {
- if (err) return t.fail('Error perform version patch')
- var testPkg = require(pkg+'/package')
- if (testPkg.version !== '0.0.1') t.fail(testPkg.version+' !== \'0.0.1\'')
- t.ok('0.0.1' === testPkg.version)
- tagExists('v0.0.1', function(err, exists) {
- t.equal(exists, false, 'git tag DOES exist')
- t.pass('git tag does not exist')
+ var child2 = spawn(git, ["init"])
+ child2.stdout.pipe(process.stdout)
+ child2.on("exit", function() {
+ npm.config.set("git-tag-version", false)
+ npm.commands.version(["patch"], function(err) {
+ if (err) return t.fail("Error perform version patch")
+ var p = path.resolve(pkg, "package")
+ var testPkg = require(p)
+ if (testPkg.version !== "0.0.1") t.fail(testPkg.version+" !== \"0.0.1\"")
+ t.equal("0.0.1", testPkg.version)
+ tagExists("v0.0.1", function(err, exists) {
+ t.ifError(err, "tag found to exist")
+ t.equal(exists, false, "git tag DOES exist")
+ t.pass("git tag does not exist")
t.end()
})
})
@@ -52,7 +50,7 @@ test("npm version <semver> without git tag", function (t) {
})
})
-test('cleanup', function(t) {
+test("cleanup", function(t) {
// windows fix for locked files
process.chdir(osenv.tmpdir())
@@ -62,12 +60,12 @@ test('cleanup', function(t) {
function setup() {
mkdirp.sync(pkg)
- mkdirp.sync(pkg + '/cache')
- fs.writeFileSync(pkg + '/package.json', JSON.stringify({
+ mkdirp.sync(cache)
+ fs.writeFileSync(path.resolve(pkg, "package.json"), JSON.stringify({
author: "Evan Lucas",
name: "version-no-tags-test",
version: "0.0.0",
description: "Test for git-tag-version flag"
- }), 'utf8')
+ }), "utf8")
process.chdir(pkg)
}
diff --git a/test/tap/view.js b/test/tap/view.js
index 568e603a8..4b9f2411e 100644
--- a/test/tap/view.js
+++ b/test/tap/view.js
@@ -40,7 +40,7 @@ test("npm view . in global mode", function(t) {
, "--registry=" + common.registry
, "--global"
], { cwd: t1dir }, function(err, code, stdout, stderr) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 1, "exit not ok")
t.similar(stderr, /Cannot use view command in global mode./m)
t.end()
@@ -54,7 +54,7 @@ test("npm view . with no package.json", function(t) {
, "."
, "--registry=" + common.registry
], { cwd: t1dir }, function(err, code, stdout, stderr) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 1, "exit not ok")
t.similar(stderr, /Invalid package.json/m)
t.end()
@@ -69,7 +69,7 @@ test("npm view . with no published package", function(t) {
, "."
, "--registry=" + common.registry
], { cwd: t3dir }, function(err, code, stdout, stderr) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 1, "exit not ok")
t.similar(stderr, /version not found/m)
s.close()
@@ -86,7 +86,7 @@ test("npm view .", function(t) {
, "."
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
var re = new RegExp("name: 'test-repo-url-https'")
t.similar(stdout, re)
@@ -105,7 +105,7 @@ test("npm view . select fields", function(t) {
, "main"
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
t.equal(stdout.trim(), "index.js", "should print `index.js`")
s.close()
@@ -123,7 +123,7 @@ test("npm view .@<version>", function(t) {
, "version"
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
t.equal(stdout.trim(), "0.0.0", "should print `0.0.0`")
s.close()
@@ -142,7 +142,7 @@ test("npm view .@<version> --json", function(t) {
, "--json"
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
t.equal(stdout.trim(), "\"0.0.0\"", "should print `\"0.0.0\"`")
s.close()
@@ -158,7 +158,7 @@ test("npm view <package name>", function(t) {
, "underscore"
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
var re = new RegExp("name: 'underscore'")
t.similar(stdout, re, "should have name `underscore`")
@@ -177,9 +177,9 @@ test("npm view <package name> --json", function(t) {
, "--json"
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- s.close()
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
+ s.close()
try {
var out = JSON.parse(stdout.trim())
t.similar(out, {
@@ -201,7 +201,7 @@ test("npm view <package name> <field>", function(t) {
, "homepage"
, "--registry=" + common.registry
], { cwd: t2dir }, function(err, code, stdout) {
- t.ifError(err, "error should not exist")
+ t.ifError(err, "view command finished successfully")
t.equal(code, 0, "exit ok")
t.equal(stdout.trim(), "http://underscorejs.org",
"homepage should equal `http://underscorejs.org`")