-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
install: better logging, no more readJSON caching
A bunch of the tests are now getting more complete from / resolved information because the contents of rewritten package.json files on disk are no longer masked by `read-package-json` memoizing fs reads of package.json files. Part of fixing npm#7074.
- Loading branch information
Showing
18 changed files
with
339 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,85 @@ | ||
var npm = npm = require("../../") | ||
var test = require("tap").test | ||
var path = require("path") | ||
var fs = require("fs") | ||
var osenv = require("osenv") | ||
var rimraf = require("rimraf") | ||
var mr = require("npm-registry-mock") | ||
var common = require("../common-tap.js") | ||
|
||
var pkg = path.resolve(__dirname, "dev-dep-duplicate") | ||
var desiredResultsPath = path.resolve(pkg, "desired-ls-results.json") | ||
|
||
test("prefers version from dependencies over devDependencies", function (t) { | ||
var fs = require('graceful-fs') | ||
var path = require('path') | ||
|
||
var mkdirp = require('mkdirp') | ||
var mr = require('npm-registry-mock') | ||
var osenv = require('osenv') | ||
var rimraf = require('rimraf') | ||
var test = require('tap').test | ||
|
||
var common = require('../common-tap.js') | ||
var npm = npm = require('../../') | ||
|
||
var pkg = path.resolve(__dirname, 'dev-dep-duplicate') | ||
|
||
var json = { | ||
author: 'Anders Janmyr', | ||
name: 'dev-dep-duplicate', | ||
version: '0.0.0', | ||
dependencies: { | ||
underscore: '1.5.1' | ||
}, | ||
devDependencies: { | ||
underscore: '1.3.1' | ||
} | ||
} | ||
|
||
var expected = { | ||
name: 'dev-dep-duplicate', | ||
version: '0.0.0', | ||
dependencies: { | ||
underscore: { | ||
version: '1.5.1', | ||
from: '[email protected]', | ||
resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz' | ||
} | ||
} | ||
} | ||
|
||
test('prefers version from dependencies over devDependencies', function (t) { | ||
t.plan(1) | ||
|
||
mr({port : common.port}, function (er, s) { | ||
mr({ port: common.port }, function (er, s) { | ||
setup(function (err) { | ||
if (err) return t.fail(err) | ||
|
||
npm.install(".", function (err) { | ||
npm.install('.', function (err) { | ||
if (err) return t.fail(err) | ||
|
||
npm.commands.ls([], true, function (err, _, results) { | ||
if (err) return t.fail(err) | ||
|
||
fs.readFile(desiredResultsPath, function (err, desired) { | ||
if (err) return t.fail(err) | ||
|
||
t.deepEqual(results, JSON.parse(desired)) | ||
s.close() | ||
t.end() | ||
}) | ||
t.deepEqual(results, expected) | ||
s.close() | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
test("cleanup", function (t) { | ||
test('cleanup', function (t) { | ||
cleanup() | ||
t.end() | ||
}) | ||
|
||
|
||
function setup (cb) { | ||
cleanup() | ||
mkdirp.sync(pkg) | ||
fs.writeFileSync( | ||
path.join(pkg, 'package.json'), | ||
JSON.stringify(json, null, 2) | ||
) | ||
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) | ||
} | ||
|
||
function cleanup () { | ||
process.chdir(osenv.tmpdir()) | ||
rimraf.sync(path.resolve(pkg, "node_modules")) | ||
rimraf.sync(path.resolve(pkg, "cache")) | ||
rimraf.sync(pkg) | ||
} |
Oops, something went wrong.