1var fs = require('graceful-fs') 2var path = require('path') 3 4var mkdirp = require('mkdirp') 5var mr = require('npm-registry-mock') 6var rimraf = require('rimraf') 7var test = require('tap').test 8 9var common = require('../common-tap.js') 10var npm = require('../../') 11 12var pkg = path.resolve(__dirname, 'outdated-new-versions') 13var cache = path.resolve(pkg, 'cache') 14 15var json = { 16 name: 'new-versions-with-outdated', 17 author: 'Rockbert', 18 version: '0.0.0', 19 dependencies: { 20 underscore: '~1.3.1' 21 }, 22 devDependencies: { 23 request: '~0.9.0' 24 } 25} 26 27test('setup', function (t) { 28 cleanup() 29 mkdirp.sync(cache) 30 fs.writeFileSync( 31 path.join(pkg, 'package.json'), 32 JSON.stringify(json, null, 2) 33 ) 34 t.end() 35}) 36 37test('dicovers new versions in outdated', function (t) { 38 process.chdir(pkg) 39 t.plan(4) 40 41 mr({ port: common.port }, function (er, s) { 42 npm.load({ cache: cache, registry: common.registry }, function () { 43 npm.outdated(function (er, d) { 44 t.ifError(er, 'npm outdated completed successfully') 45 t.is(process.exitCode, 1, 'exitCode set to 1') 46 process.exitCode = 0 47 for (var i = 0; i < d.length; i++) { 48 if (d[i][1] === 'underscore') t.equal('1.5.1', d[i][4]) 49 if (d[i][1] === 'request') t.equal('2.27.0', d[i][4]) 50 } 51 s.close() 52 t.end() 53 }) 54 }) 55 }) 56}) 57 58test('cleanup', function (t) { 59 cleanup() 60 t.end() 61}) 62 63function cleanup () { 64 rimraf.sync(pkg) 65} 66