1'use strict' 2 3const common = require('../common-tap.js') 4const fs = require('fs') 5const mr = require('npm-registry-mock') 6const path = require('path') 7const test = require('tap').test 8 9const pkg = common.pkg 10 11const EXEC_OPTS = { cwd: pkg } 12 13const json = { 14 author: 'Rockbert', 15 name: 'shrinkwrap-empty-deps', 16 version: '0.0.0', 17 dependencies: {}, 18 devDependencies: {} 19} 20 21test('setup', function (t) { 22 fs.writeFileSync( 23 path.join(pkg, 'package.json'), 24 JSON.stringify(json, null, 2) 25 ) 26 27 process.chdir(pkg) 28 t.end() 29}) 30 31test('returns a list of removed items', function (t) { 32 mr({ port: common.port }, function (er, s) { 33 common.npm( 34 [ 35 '--registry', common.registry, 36 '--loglevel', 'silent', 37 'shrinkwrap' 38 ], 39 EXEC_OPTS, 40 function (err, code, stdout, stderr) { 41 t.ifError(err, 'shrinkwrap ran without issue') 42 t.notOk(code, 'shrinkwrap ran without raising error code') 43 44 fs.readFile(path.resolve(pkg, 'npm-shrinkwrap.json'), function (err, found) { 45 t.ifError(err, 'read npm-shrinkwrap.json without issue') 46 t.same( 47 JSON.parse(found).dependencies, 48 undefined, 49 'shrinkwrap handled empty deps without exploding' 50 ) 51 52 s.close() 53 t.end() 54 }) 55 } 56 ) 57 }) 58}) 59