function setup () { cleanup() mkdirp.sync(pkg) fs.writeFileSync( path.join(pkg, 'package.json'), JSON.stringify(json, null, 2) ) fs.writeFileSync( path.join(pkg, 'package-lock.json'), JSON.stringify(brokenLockfile, null, 2) ) process.chdir(pkg) }
test('setup', function (t) { var root = path.resolve(pkg, target) mkdirp.sync(root) fs.writeFileSync( path.join(root, 'package.json'), JSON.stringify(json, null, 2) ) mkdirp.sync(path.resolve(pkg, 'node_modules')) t.end() })
const setup = lineEnding => t => { rimraf(pkg, er => { if (er) { throw er } mkdirp.sync(path.resolve(pkg, 'node_modules')) var jsonStr = JSON.stringify(json, null, 2) if (lineEnding === '\r\n') { jsonStr = jsonStr.replace(/\n/g, '\r\n') } fs.writeFileSync( path.join(pkg, 'package.json'), jsonStr ) t.end() }) }
test('npm install execution order', function (t) { const packageJson = { name: 'life-test', version: '0.0.1', description: 'Test for npm install execution order', scripts: { install: 'true', preinstall: 'true', preshrinkwrap: 'true', postinstall: 'true', postshrinkwrap: 'true', shrinkwrap: 'true' } } fs.writeFileSync(path.resolve(pkg, 'package.json'), JSON.stringify(packageJson), 'utf8') common.npm(['install', '--loglevel=error'], { cwd: pkg }, function (err, code, stdout, stderr) { if (err) throw err t.comment(stdout) t.comment(stderr) const steps = ['preinstall', 'install', 'postinstall', 'preshrinkwrap', 'shrinkwrap', 'postshrinkwrap'] const expectedLines = steps.map(function (step) { return '> ' + packageJson.name + '@' + packageJson.version + ' ' + step }) t.match(stdout, new RegExp(expectedLines.map(common.escapeForRe).join('(.|\n)*'))) t.end() }) })
t.test('setup', function (t) { mkdirp.sync(target) fs.writeFileSync( path.join(target, 'package.json'), JSON.stringify(localDependencyJson, null, 2) ) mkdirp.sync(pkg) fs.writeFileSync( path.join(pkg, 'package.json'), JSON.stringify(dependentJson, null, 2) ) mr({ port: common.port }, (er, s) => { if (er) { throw er } server = s t.end() }) })
test('setup', function (t) { mkdirp.sync(path.join(pkg, 'dependency')) fs.writeFileSync( path.join(pkg, 'dependency', 'package.json'), JSON.stringify(dependency, null, 2) ) mkdirp.sync(path.join(pkg, 'node_modules')) fs.writeFileSync( path.join(pkg, 'package.json'), JSON.stringify(json, null, 2) ) // Disable package-lock fs.writeFileSync( path.join(pkg, '.npmrc'), 'package-lock=false\n' ) t.end() })
test('setup', function (t) { mkdirp.sync(pkg) fs.writeFileSync( path.join(pkg, 'package.json'), JSON.stringify(parent, null, 2) fs.writeFileSync( path.join(pkg, 'package-lock.json'), JSON.stringify(parentLock, null, 2) fs.writeFileSync( path.join(root, 'children', 'child-1-1', 'package.json'), JSON.stringify(child11, null, 2) fs.writeFileSync( path.join(root, 'children', 'child-1-1', 'package-lock.json'), JSON.stringify(child11Lock, null, 2) fs.writeFileSync( path.join(root, 'children', 'child-1-2', 'package.json'), JSON.stringify(child12, null, 2) fs.writeFileSync( path.join(root, 'children', 'child-1-2', 'package-lock.json'), JSON.stringify(child12Lock, null, 2) fs.writeFileSync( path.join(root, 'children', 'child-2', 'package.json'), JSON.stringify(child2, null, 2)