1 var fs = require('graceful-fs')
2 var path = require('path')
3 var existsSync = fs.existsSync || path.existsSync
5 var mkdirp = require('mkdirp')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
10 var common = require('../common-tap.js')
12 var pkg = path.join(__dirname, 'install-cli-production')
14 var EXEC_OPTS = { cwd: pkg }
17 name: 'install-cli-production',
18 description: 'fixture',
21 prepublish: 'exit 123'
24 dependency: 'file:./dependency'
27 'dev-dependency': 'file:./dev-dependency'
33 description: 'fixture',
38 name: 'dev-dependency',
39 description: 'fixture',
43 test('setup', function (t) {
44 mkdirp.sync(path.join(pkg, 'dependency'))
46 path.join(pkg, 'dependency', 'package.json'),
47 JSON.stringify(dependency, null, 2)
50 mkdirp.sync(path.join(pkg, 'devDependency'))
52 path.join(pkg, 'devDependency', 'package.json'),
53 JSON.stringify(devDependency, null, 2)
56 mkdirp.sync(path.join(pkg, 'node_modules'))
58 path.join(pkg, 'package.json'),
59 JSON.stringify(json, null, 2)
66 test('\'npm install --production\' should only install dependencies', function (t) {
67 common.npm(['install', '--production'], EXEC_OPTS, function (err, code) {
68 t.ifError(err, 'install production successful')
69 t.equal(code, 0, 'npm install did not raise error code')
71 JSON.parse(fs.readFileSync(
72 path.resolve(pkg, 'node_modules/dependency/package.json'), 'utf8')
74 'dependency was installed'
77 existsSync(path.resolve(pkg, 'node_modules/dev-dependency/package.json')),
78 'devDependency was NOT installed'
84 test('cleanup', function (t) {
85 process.chdir(osenv.tmpdir())