]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/install-cli-production.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / install-cli-production.js
1 var fs = require('graceful-fs')
2 var path = require('path')
3 var existsSync = fs.existsSync || path.existsSync
4
5 var mkdirp = require('mkdirp')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
9
10 var common = require('../common-tap.js')
11
12 var pkg = path.join(__dirname, 'install-cli-production')
13
14 var EXEC_OPTS = { cwd: pkg }
15
16 var json = {
17   name: 'install-cli-production',
18   description: 'fixture',
19   version: '0.0.0',
20   scripts: {
21     prepublish: 'exit 123'
22   },
23   dependencies: {
24     dependency: 'file:./dependency'
25   },
26   devDependencies: {
27     'dev-dependency': 'file:./dev-dependency'
28   }
29 }
30
31 var dependency = {
32   name: 'dependency',
33   description: 'fixture',
34   version: '0.0.0'
35 }
36
37 var devDependency = {
38   name: 'dev-dependency',
39   description: 'fixture',
40   version: '0.0.0'
41 }
42
43 test('setup', function (t) {
44   mkdirp.sync(path.join(pkg, 'dependency'))
45   fs.writeFileSync(
46     path.join(pkg, 'dependency', 'package.json'),
47     JSON.stringify(dependency, null, 2)
48   )
49
50   mkdirp.sync(path.join(pkg, 'devDependency'))
51   fs.writeFileSync(
52     path.join(pkg, 'devDependency', 'package.json'),
53     JSON.stringify(devDependency, null, 2)
54   )
55
56   mkdirp.sync(path.join(pkg, 'node_modules'))
57   fs.writeFileSync(
58     path.join(pkg, 'package.json'),
59     JSON.stringify(json, null, 2)
60   )
61
62   process.chdir(pkg)
63   t.end()
64 })
65
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')
70     t.ok(
71       JSON.parse(fs.readFileSync(
72         path.resolve(pkg, 'node_modules/dependency/package.json'), 'utf8')
73       ),
74       'dependency was installed'
75     )
76     t.notOk(
77       existsSync(path.resolve(pkg, 'node_modules/dev-dependency/package.json')),
78       'devDependency was NOT installed'
79     )
80     t.end()
81   })
82 })
83
84 test('cleanup', function (t) {
85   process.chdir(osenv.tmpdir())
86   rimraf.sync(pkg)
87   t.end()
88 })