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:
authorRebecca Turner <me@re-becca.org>2015-08-19 16:05:22 +0300
committerRebecca Turner <me@re-becca.org>2015-08-21 22:26:46 +0300
commit02420dc73ae185144267912e461da2effe90341d (patch)
treef084d41972f206dbe80ff07f2276b8c1e5112493 /test
parentad3714c2e52778c99c69c4be8e3beb350396708b (diff)
ls: Elminate warnings about missing package.json at top level
PR-URL: https://github.com/npm/npm/pull/9343 Fixes: #9113
Diffstat (limited to 'test')
-rw-r--r--test/tap/ls-l-depth-0.js2
-rw-r--r--test/tap/ls-top-errors.js71
2 files changed, 72 insertions, 1 deletions
diff --git a/test/tap/ls-l-depth-0.js b/test/tap/ls-l-depth-0.js
index 9aed9da21..24fa06290 100644
--- a/test/tap/ls-l-depth-0.js
+++ b/test/tap/ls-l-depth-0.js
@@ -77,7 +77,7 @@ test('#6311: npm ll --depth=0 duplicates listing', function (t) {
EXEC_OPTS,
function (err, code, stdout, stderr) {
t.ifError(err, 'npm ll ran without error')
- t.is(code, 1, 'npm ll complained about there being no package.json')
+ t.is(code, 0, 'npm ll exited cleanly')
t.notOk(stderr, 'npm ll ran silently')
t.equal(
stdout,
diff --git a/test/tap/ls-top-errors.js b/test/tap/ls-top-errors.js
new file mode 100644
index 000000000..69b8b299c
--- /dev/null
+++ b/test/tap/ls-top-errors.js
@@ -0,0 +1,71 @@
+'use strict'
+var fs = require('fs')
+var path = require('path')
+
+var test = require('tap').test
+var mkdirp = require('mkdirp')
+var rimraf = require('rimraf')
+
+var common = require('../common-tap')
+
+var pkg = path.resolve(__dirname, path.basename(__filename, '.js'))
+var pathModA = path.join(pkg, 'node_modules', 'moduleA')
+var pathModB = path.join(pkg, 'node_modules', 'moduleB')
+
+var modA = {
+ name: 'moduleA',
+ version: '1.0.0',
+ _requiredBy: [ '#USER', '/moduleB' ],
+ dependencies: {
+ moduleB: '1.0.0'
+ }
+}
+var modB = {
+ name: 'moduleB',
+ version: '1.0.0',
+ _requiredBy: [ '/moduleA' ],
+ dependencies: {
+ moduleA: '1.0.0'
+ }
+}
+
+function setup () {
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ '{broken json'
+ )
+ mkdirp.sync(pathModA)
+ fs.writeFileSync(
+ path.join(pathModA, 'package.json'),
+ JSON.stringify(modA, null, 2)
+ )
+ mkdirp.sync(pathModB)
+ fs.writeFileSync(
+ path.join(pathModB, 'package.json'),
+ JSON.stringify(modB, null, 2)
+ )
+}
+
+function cleanup () {
+ rimraf.sync(pkg)
+}
+
+test('setup', function (t) {
+ cleanup()
+ setup()
+ t.end()
+})
+
+test('ls-top-errors', function (t) {
+ common.npm(['ls'], {cwd: pkg}, function (er, code, stdout, stderr) {
+ t.ifErr(er, 'install finished successfully')
+ t.match(stderr, /Failed to parse json/)
+ t.end()
+ })
+})
+
+test('cleanup', function (t) {
+ cleanup()
+ t.end()
+})