1var path = require('path') 2 3var test = require('tap').test 4var mkdirp = require('mkdirp') 5var fs = require('graceful-fs') 6var rimraf = require('rimraf') 7 8var common = require('../common-tap.js') 9var npm = require('../../') 10 11// config 12var pkg = common.pkg 13var cache = common.cache 14var json = { 15 name: 'outdated-git', 16 author: 'Rocko Artischocko', 17 description: 'fixture', 18 version: '0.0.1', 19 main: 'index.js', 20 dependencies: { 21 'foo-github': 'robertkowalski/foo', 22 'foo-private': 'git://github.com/robertkowalski/foo-private.git', 23 'foo-private-credentials': 'git://user:pass@github.com/robertkowalski/foo-private.git' 24 } 25} 26 27test('setup', function (t) { 28 setup() 29 t.end() 30}) 31 32test('discovers new versions in outdated', function (t) { 33 process.chdir(pkg) 34 t.plan(7) 35 npm.load({cache: cache, registry: common.registry, loglevel: 'silent'}, function () { 36 npm.commands.outdated([], function (er, d) { 37 t.ifError(er, 'npm outdated completed successfully') 38 t.is(process.exitCode, 1, 'exitCode set to 1') 39 process.exitCode = 0 40 t.equal(d[0][3], 'git') 41 t.equal(d[0][4], 'git') 42 t.equal(d[0][5], 'github:robertkowalski/foo') 43 t.equal(d[1][5], 'git://github.com/robertkowalski/foo-private.git') 44 t.equal(d[2][5], 'git://user:pass@github.com/robertkowalski/foo-private.git') 45 }) 46 }) 47}) 48 49test('cleanup', function (t) { 50 cleanup() 51 t.end() 52}) 53 54function setup () { 55 mkdirp.sync(cache) 56 fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2), 'utf8') 57} 58 59function cleanup () { 60 rimraf.sync(pkg) 61} 62