1var fs = require('graceful-fs') 2var path = require('path') 3 4var mr = require('npm-registry-mock') 5var test = require('tap').test 6 7var npm = require('../../') 8var common = require('../common-tap') 9 10var pkg = common.pkg 11 12var json = { 13 name: 'outdated-depth', 14 version: '1.2.3', 15 dependencies: { 16 underscore: '1.3.1', 17 'npm-test-peer-deps': '0.0.0' 18 } 19} 20 21test('setup', function (t) { 22 fs.writeFileSync( 23 path.join(pkg, 'package.json'), 24 JSON.stringify(json, null, 2) 25 ) 26 process.chdir(pkg) 27 28 t.end() 29}) 30 31test('outdated depth zero', function (t) { 32 var expected = [ 33 pkg, 34 'underscore', 35 '1.3.1', 36 '1.3.1', 37 '1.5.1', 38 '1.3.1', 39 null 40 ] 41 42 mr({ port: common.port }, function (er, s) { 43 npm.load( 44 { 45 depth: 0, 46 loglevel: 'silent', 47 registry: common.registry 48 }, 49 function () { 50 npm.install('.', function (er) { 51 if (er) throw new Error(er) 52 npm.outdated(function (err, d) { 53 if (err) { 54 throw err 55 } 56 t.is(process.exitCode, 1, 'exit code set to 1') 57 process.exitCode = 0 58 t.deepEqual(d[0], expected) 59 t.equal(d.length, 1) 60 npm.config.set('depth', 1) 61 npm.outdated(function (err, d) { 62 t.equal(d.length, 2) 63 if (err) { 64 throw err 65 } 66 t.is(process.exitCode, 1, 'exit code set to 1') 67 process.exitCode = 0 68 s.close() 69 t.end() 70 }) 71 }) 72 }) 73 } 74 ) 75 }) 76}) 77