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:
authorSreeram Jayan <sreeram.jayan@cerner.com>2019-03-20 18:06:06 +0300
committerisaacs <i@izs.me>2019-06-30 06:23:54 +0300
commit87fef4e356f30941f2ee39f2f774ad2086239a00 (patch)
tree428685f4541af309408fed12f855c56ce1d48c03 /test
parentd9238af0b4a3d368b79e54d1636e4aab80bb537f (diff)
fix: Always return JSON for outdated --json
Close: https://github.com/npm/cli/pull/176 EDIT: Added test, do not set exitStatus to 1 if we're just printing an empty list as JSON. -- @isaacs
Diffstat (limited to 'test')
-rw-r--r--test/tap/outdated-json.js42
1 files changed, 30 insertions, 12 deletions
diff --git a/test/tap/outdated-json.js b/test/tap/outdated-json.js
index e0040d028..77db52cc7 100644
--- a/test/tap/outdated-json.js
+++ b/test/tap/outdated-json.js
@@ -1,10 +1,7 @@
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')
@@ -42,8 +39,6 @@ var expected = {
}
test('setup', function (t) {
- cleanup()
- mkdirp.sync(pkg)
fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json, null, 2)
@@ -92,14 +87,37 @@ test('it should log json data', function (t) {
)
})
+test('it should log json data even when the list is empty', function (t) {
+ common.npm(
+ [
+ 'rm',
+ 'request',
+ 'underscore'
+ ],
+ EXEC_OPTS,
+ function (er, code, stdout) {
+ t.ifError(er, 'run without error')
+ t.is(code, 0, 'successful exit status')
+ common.npm(
+ [
+ '--registry', common.registry,
+ '--silent',
+ '--json',
+ 'outdated'
+ ],
+ EXEC_OPTS,
+ function (er, code, stdout) {
+ t.ifError(er, 'run without error')
+ t.is(code, 0, 'successful exit status')
+ t.same(JSON.parse(stdout), {}, 'got an empty object printed')
+ t.end()
+ }
+ )
+ }
+ )
+})
+
test('cleanup', function (t) {
server.close()
- cleanup()
t.end()
})
-
-function cleanup () {
- // windows fix for locked files
- process.chdir(osenv.tmpdir())
- rimraf.sync(pkg)
-}