diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-06-23 08:18:52 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-06-26 03:27:33 +0300 |
commit | b50be6aff34a739ca43de65f546e743d1a9975b9 (patch) | |
tree | 3153fd3a271245b8a05a9be196286fbe31fc9d44 /test/tap/shrinkwrap-local-dependency.js | |
parent | 7c5ebe0552b7b5d0cdca34d28c4f16fe794ff2ff (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/shrinkwrap-local-dependency.js')
-rw-r--r-- | test/tap/shrinkwrap-local-dependency.js | 101 |
1 files changed, 50 insertions, 51 deletions
diff --git a/test/tap/shrinkwrap-local-dependency.js b/test/tap/shrinkwrap-local-dependency.js index ffbde6574..8d7c0712f 100644 --- a/test/tap/shrinkwrap-local-dependency.js +++ b/test/tap/shrinkwrap-local-dependency.js @@ -1,63 +1,62 @@ -var test = require("tap").test -var path = require("path") -var fs = require("fs") -var osenv = require("osenv") -var rimraf = require("rimraf") -var mkdirp = require("mkdirp") -var common = require("../common-tap.js") - -var PKG_DIR = path.resolve(__dirname, "shrinkwrap-local-dependency") -var CACHE_DIR = path.resolve(PKG_DIR, "cache") -var DEP_DIR = path.resolve(PKG_DIR, "dep") +var test = require('tap').test +var path = require('path') +var fs = require('fs') +var osenv = require('osenv') +var rimraf = require('rimraf') +var mkdirp = require('mkdirp') +var common = require('../common-tap.js') + +var PKG_DIR = path.resolve(__dirname, 'shrinkwrap-local-dependency') +var CACHE_DIR = path.resolve(PKG_DIR, 'cache') +var DEP_DIR = path.resolve(PKG_DIR, 'dep') var desired = { - "name": "npm-test-shrinkwrap-local-dependency", - "version": "0.0.0", - "dependencies": { - "npm-test-shrinkwrap-local-dependency-dep": { - "version": "0.0.0", - "from": "dep", - "resolved": "file:dep" + 'name': 'npm-test-shrinkwrap-local-dependency', + 'version': '0.0.0', + 'dependencies': { + 'npm-test-shrinkwrap-local-dependency-dep': { + 'version': '0.0.0', + 'from': 'dep', + 'resolved': 'file:dep' } } } var root = { - "author": "Thomas Torp", - "name": "npm-test-shrinkwrap-local-dependency", - "version": "0.0.0", - "dependencies": { - "npm-test-shrinkwrap-local-dependency-dep": "file:./dep" + 'author': 'Thomas Torp', + 'name': 'npm-test-shrinkwrap-local-dependency', + 'version': '0.0.0', + 'dependencies': { + 'npm-test-shrinkwrap-local-dependency-dep': 'file:./dep' } } var dependency = { - "author": "Thomas Torp", - "name": "npm-test-shrinkwrap-local-dependency-dep", - "version": "0.0.0" + 'author': 'Thomas Torp', + 'name': 'npm-test-shrinkwrap-local-dependency-dep', + 'version': '0.0.0' } - -test("shrinkwrap uses resolved with file: on local deps", function(t) { +test('shrinkwrap uses resolved with file: on local deps', function (t) { setup() common.npm( - ["--cache="+CACHE_DIR, "--loglevel=silent", "install", "."], + ['--cache=' + CACHE_DIR, '--loglevel=silent', 'install', '.'], {}, function (err, code) { - t.ifError(err, "npm install worked") - t.equal(code, 0, "npm exited normally") + t.ifError(err, 'npm install worked') + t.equal(code, 0, 'npm exited normally') common.npm( - ["--cache="+CACHE_DIR, "--loglevel=silent", "shrinkwrap"], + ['--cache=' + CACHE_DIR, '--loglevel=silent', 'shrinkwrap'], {}, function (err, code) { - t.ifError(err, "npm shrinkwrap worked") - t.equal(code, 0, "npm exited normally") + t.ifError(err, 'npm shrinkwrap worked') + t.equal(code, 0, 'npm exited normally') - fs.readFile("npm-shrinkwrap.json", { encoding : "utf8" }, function (err, data) { - t.ifError(err, "read file correctly") - t.deepEqual(JSON.parse(data), desired, "shrinkwrap looks correct") + fs.readFile('npm-shrinkwrap.json', { encoding: 'utf8' }, function (err, data) { + t.ifError(err, 'read file correctly') + t.deepEqual(JSON.parse(data), desired, 'shrinkwrap looks correct') t.end() }) @@ -67,22 +66,22 @@ test("shrinkwrap uses resolved with file: on local deps", function(t) { ) }) -test('"npm install" should install local packages from shrinkwrap', function (t) { +test("'npm install' should install local packages from shrinkwrap", function (t) { cleanNodeModules() common.npm( - ["--cache="+CACHE_DIR, "--loglevel=silent", "install", "."], + ['--cache=' + CACHE_DIR, '--loglevel=silent', 'install', '.'], {}, function (err, code) { - t.ifError(err, "install ran correctly") - t.notOk(code, "npm install exited with code 0") + t.ifError(err, 'install ran correctly') + t.notOk(code, 'npm install exited with code 0') var dependencyPackageJson = path.resolve( PKG_DIR, - "node_modules/npm-test-shrinkwrap-local-dependency-dep/package.json" + 'node_modules/npm-test-shrinkwrap-local-dependency-dep/package.json' ) t.ok( - JSON.parse(fs.readFileSync(dependencyPackageJson, "utf8")), - "package with local dependency installed from shrinkwrap" + JSON.parse(fs.readFileSync(dependencyPackageJson, 'utf8')), + 'package with local dependency installed from shrinkwrap' ) t.end() @@ -90,32 +89,32 @@ test('"npm install" should install local packages from shrinkwrap', function (t) ) }) -test("cleanup", function(t) { +test('cleanup', function (t) { cleanup() t.end() }) -function setup() { +function setup () { cleanup() mkdirp.sync(PKG_DIR) mkdirp.sync(CACHE_DIR) mkdirp.sync(DEP_DIR) fs.writeFileSync( - path.resolve(PKG_DIR, "package.json"), + path.resolve(PKG_DIR, 'package.json'), JSON.stringify(root, null, 2) ) fs.writeFileSync( - path.resolve(DEP_DIR, "package.json"), + path.resolve(DEP_DIR, 'package.json'), JSON.stringify(dependency, null, 2) ) process.chdir(PKG_DIR) } -function cleanNodeModules() { - rimraf.sync(path.resolve(PKG_DIR, "node_modules")) +function cleanNodeModules () { + rimraf.sync(path.resolve(PKG_DIR, 'node_modules')) } -function cleanup() { +function cleanup () { process.chdir(osenv.tmpdir()) cleanNodeModules() rimraf.sync(PKG_DIR) |