1var fs = require('fs') 2var path = require('path') 3 4var mkdirp = require('mkdirp') 5var mr = require('npm-registry-mock') 6var test = require('tap').test 7 8var npm = require('../../') 9 10var common = require('../common-tap.js') 11var pkg = common.pkg 12 13var desired = { 14 name: 'npm-test-shrinkwrap-prod-dependency', 15 version: '0.0.0', 16 dependencies: { 17 request: { 18 version: '0.9.0', 19 resolved: common.registry + '/request/-/request-0.9.0.tgz', 20 integrity: 'sha1-EEn1mm9GWI5tAwkh+7hMovDCcU4=' 21 }, 22 underscore: { 23 dev: true, 24 version: '1.5.1', 25 resolved: common.registry + '/underscore/-/underscore-1.5.1.tgz', 26 integrity: 'sha1-0r3oF9F2/63olKtxRY5oKhS4bck=' 27 } 28 } 29} 30 31var json = { 32 author: 'Domenic Denicola', 33 name: 'npm-test-shrinkwrap-prod-dependency', 34 version: '0.0.0', 35 dependencies: { 36 request: '0.9.0' 37 }, 38 devDependencies: { 39 underscore: '1.5.1' 40 } 41} 42 43test('setup', function (t) { 44 mkdirp.sync(pkg) 45 fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(json, null, 2)) 46 process.chdir(pkg) 47 48 var allOpts = { 49 cache: common.cache, 50 registry: common.registry 51 } 52 53 npm.load(allOpts, t.end) 54}) 55 56test('mock registry', t => { 57 mr({port: common.port}, function (er, s) { 58 t.parent.teardown(() => s.close()) 59 t.end() 60 }) 61}) 62 63test("shrinkwrap --dev doesn't strip out prod dependencies", t => { 64 t.plan(1) 65 npm.install('.', function (err) { 66 if (err) return t.fail(err) 67 68 npm.config.set('dev', true) 69 npm.commands.shrinkwrap([], true, function (err, results) { 70 if (err) return t.fail(err) 71 72 t.deepEqual(results.dependencies, desired.dependencies) 73 t.end() 74 }) 75 }) 76}) 77