Skip to content

Commit

Permalink
Fixed lint issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismeyersfsu authored and othiym23 committed Oct 4, 2014
1 parent 8d6bfcb commit 80557fc
Show file tree
Hide file tree
Showing 65 changed files with 747 additions and 720 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ npm-debug.log
/test/packages/npm-test-depends-on-spark/which-spark.log
/test/packages/test-package/random-data.txt
/test/root
/test/npm_cache
/node_modules/marked-man
/node_modules/tap
/node_modules/nock
Expand Down
26 changes: 13 additions & 13 deletions test/common-tap.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -40,5 +40,5 @@ exports.npm = function (cmd, opts, cb) {
child.on("close", function (code) {
cb(null, code, stdout, stderr)
})
return child;
return child
}
1 change: 1 addition & 0 deletions test/tap/00-check-mock-dep.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/tap/00-verify-bundle-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
14 changes: 7 additions & 7 deletions test/tap/00-verify-ls-ok.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
44 changes: 22 additions & 22 deletions test/tap/404-parent.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
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()
})

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)
}

Expand Down
4 changes: 2 additions & 2 deletions test/tap/cache-add-unpublished.js
Original file line number Diff line number Diff line change
@@ -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

Expand Down
44 changes: 21 additions & 23 deletions test/tap/config-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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)
}
})

Expand Down
15 changes: 8 additions & 7 deletions test/tap/dedupe.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 8 additions & 7 deletions test/tap/false_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
})
}
12 changes: 6 additions & 6 deletions test/tap/git-cache-locking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand All @@ -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
Expand All @@ -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()
})
4 changes: 2 additions & 2 deletions test/tap/global-prefix-set-in-userconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down
2 changes: 1 addition & 1 deletion test/tap/ignore-install-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})
Expand Down
Loading

0 comments on commit 80557fc

Please sign in to comment.