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
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-06-23 08:18:52 +0300
committerRebecca Turner <me@re-becca.org>2015-06-26 03:27:33 +0300
commitb50be6aff34a739ca43de65f546e743d1a9975b9 (patch)
tree3153fd3a271245b8a05a9be196286fbe31fc9d44 /test/tap/locker.js
parent7c5ebe0552b7b5d0cdca34d28c4f16fe794ff2ff (diff)
src: make the npm source comply with `standard`
This is a huge set of mostly mechanical changes. Going forward, all changes to the npm source base are expected to comply with `standard`, and it's been integrated into the test suite to enforce that. There are a few notes below about specific classes of changes that need to be handled specially for npm's code base. standard: "Expected error to be handled." `standard` only expects errors spelled "err" to be handled. `npm-registry-mock` never actually invokes its callback with an error, so in some cases I just changed it to be spelled "er" and called it good. standard: "Expected a "break" statement before 'case'." This behavior is actually on purpose, and I don't feel like rewriting the affected code right now (or, you know, ever). So I added code comments disabling the checks in the three applicable changes. standard: "x is a function." Rebinding functions created via declarations (as opposed to expressions) is a no-no? PR-URL: https://github.com/npm/npm/pull/8668
Diffstat (limited to 'test/tap/locker.js')
-rw-r--r--test/tap/locker.js78
1 files changed, 39 insertions, 39 deletions
diff --git a/test/tap/locker.js b/test/tap/locker.js
index bc43c30e9..8c548095f 100644
--- a/test/tap/locker.js
+++ b/test/tap/locker.js
@@ -1,54 +1,54 @@
-var test = require("tap").test
- , path = require("path")
- , fs = require("graceful-fs")
- , crypto = require("crypto")
- , rimraf = require("rimraf")
- , osenv = require("osenv")
- , mkdirp = require("mkdirp")
- , npm = require("../../")
- , locker = require("../../lib/utils/locker.js")
- , lock = locker.lock
- , unlock = locker.unlock
+var test = require('tap').test
+var path = require('path')
+var fs = require('graceful-fs')
+var crypto = require('crypto')
+var rimraf = require('rimraf')
+var osenv = require('osenv')
+var mkdirp = require('mkdirp')
+var npm = require('../../')
+var locker = require('../../lib/utils/locker.js')
+var lock = locker.lock
+var unlock = locker.unlock
-var pkg = path.join(__dirname, "/locker")
- , cache = path.join(pkg, "/cache")
- , tmp = path.join(pkg, "/tmp")
- , nm = path.join(pkg, "/node_modules")
+var pkg = path.join(__dirname, '/locker')
+var cache = path.join(pkg, '/cache')
+var tmp = path.join(pkg, '/tmp')
+var nm = path.join(pkg, '/node_modules')
function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
}
-test("setup", function (t) {
+test('setup', function (t) {
cleanup()
mkdirp.sync(cache)
mkdirp.sync(tmp)
t.end()
})
-test("locking file puts lock in correct place", function (t) {
+test('locking file puts lock in correct place', function (t) {
npm.load({cache: cache, tmpdir: tmp}, function (er) {
- t.ifError(er, "npm bootstrapped OK")
+ t.ifError(er, 'npm bootstrapped OK')
- var n = "correct"
- , c = n.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "")
- , p = path.resolve(nm, n)
- , h = crypto.createHash("sha1").update(p).digest("hex")
- , l = c.substr(0, 24)+"-"+h.substr(0, 16)+".lock"
- , v = path.join(cache, "_locks", l)
+ var n = 'correct'
+ var c = n.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '')
+ var p = path.resolve(nm, n)
+ var h = crypto.createHash('sha1').update(p).digest('hex')
+ var l = c.substr(0, 24) + '-' + h.substr(0, 16) + '.lock'
+ var v = path.join(cache, '_locks', l)
lock(nm, n, function (er) {
- t.ifError(er, "locked path")
+ t.ifError(er, 'locked path')
fs.exists(v, function (found) {
- t.ok(found, "lock found OK")
+ t.ok(found, 'lock found OK')
unlock(nm, n, function (er) {
- t.ifError(er, "unlocked path")
+ t.ifError(er, 'unlocked path')
fs.exists(v, function (found) {
- t.notOk(found, "lock deleted OK")
+ t.notOk(found, 'lock deleted OK')
t.end()
})
})
@@ -57,33 +57,33 @@ test("locking file puts lock in correct place", function (t) {
})
})
-test("unlocking out of order errors out", function (t) {
+test('unlocking out of order errors out', function (t) {
npm.load({cache: cache, tmpdir: tmp}, function (er) {
- t.ifError(er, "npm bootstrapped OK")
+ t.ifError(er, 'npm bootstrapped OK')
- var n = "busted"
- , c = n.replace(/[^a-zA-Z0-9]+/g, "-").replace(/^-+|-+$/g, "")
- , p = path.resolve(nm, n)
- , h = crypto.createHash("sha1").update(p).digest("hex")
- , l = c.substr(0, 24)+"-"+h.substr(0, 16)+".lock"
- , v = path.join(cache, "_locks", l)
+ var n = 'busted'
+ var c = n.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '')
+ var p = path.resolve(nm, n)
+ var h = crypto.createHash('sha1').update(p).digest('hex')
+ var l = c.substr(0, 24) + '-' + h.substr(0, 16) + '.lock'
+ var v = path.join(cache, '_locks', l)
fs.exists(v, function (found) {
- t.notOk(found, "no lock to unlock")
+ t.notOk(found, 'no lock to unlock')
t.throws(function () {
unlock(nm, n, function () {
t.fail("shouldn't get here")
t.end()
})
- }, "blew up as expected")
+ }, 'blew up as expected')
t.end()
})
})
})
-test("cleanup", function (t) {
+test('cleanup', function (t) {
cleanup()
t.end()
})