1var fs = require('graceful-fs') 2var path = require('path') 3 4var mkdirp = require('mkdirp') 5var test = require('tap').test 6 7var common = require('../common-tap.js') 8 9var pkg = common.pkg 10 11var EXEC_OPTS = { cwd: pkg } 12 13var json = { 14 name: 'install-test-cli-without-package-lock', 15 description: 'fixture', 16 version: '0.0.0', 17 dependencies: { 18 dependency: 'file:./dependency' 19 } 20} 21 22var dependency = { 23 name: 'dependency', 24 description: 'fixture', 25 version: '0.0.0' 26} 27 28test('setup', function (t) { 29 mkdirp.sync(path.join(pkg, 'dependency')) 30 fs.writeFileSync( 31 path.join(pkg, 'dependency', 'package.json'), 32 JSON.stringify(dependency, null, 2) 33 ) 34 35 mkdirp.sync(path.join(pkg, 'node_modules')) 36 fs.writeFileSync( 37 path.join(pkg, 'package.json'), 38 JSON.stringify(json, null, 2) 39 ) 40 41 // Disable package-lock 42 fs.writeFileSync( 43 path.join(pkg, '.npmrc'), 44 'package-lock=false\n' 45 ) 46 t.end() 47}) 48 49test('\'npm install-test\' should not generate package-lock.json.*', function (t) { 50 common.npm(['install-test'], EXEC_OPTS, function (err, code, stderr, stdout) { 51 if (err) throw err 52 t.comment(stdout.trim()) 53 t.comment(stderr.trim()) 54 t.is(code, 0, 'npm install did not raise error code') 55 var files = fs.readdirSync(pkg).filter(function (f) { 56 return f.indexOf('package-lock.json.') === 0 57 }) 58 t.notOk( 59 files.length > 0, 60 'package-lock.json.* should not be generated: ' + files 61 ) 62 t.end() 63 }) 64}) 65