]> 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-scoped-with-peer-dependency.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-scoped-with-peer-dependency.js
1 var fs = require('fs')
2 var path = require('path')
3
4 var mkdirp = require('mkdirp')
5 var osenv = require('osenv')
6 var rimraf = require('rimraf')
7 var test = require('tap').test
8
9 var common = require('../common-tap.js')
10 var pkg = path.join(__dirname, 'install-scoped-with-peer-dependency')
11 var local = path.join(pkg, 'package')
12
13 var EXEC_OPTS = { }
14
15 var json = {
16   name: '@scope/package',
17   version: '0.0.0',
18   peerDependencies: {
19     underscore: '*'
20   }
21 }
22
23 test('setup', function (t) {
24   setup()
25
26   t.end()
27 })
28
29 test('it should install peerDependencies in same tree level as the parent package', function (t) {
30   common.npm(['install', './package'], EXEC_OPTS, function (err, code, stdout, stderr) {
31     t.ifError(err, 'install local package successful')
32     t.equal(code, 0, 'npm install exited with code')
33     t.notOk(stderr, 'npm install exited without any error output')
34
35     var p = path.resolve(pkg, 'node_modules/underscore/package.json')
36     t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
37     t.end()
38   })
39 })
40
41 test('cleanup', function (t) {
42   cleanup()
43   t.end()
44 })
45
46 function setup () {
47   cleanup()
48   mkdirp.sync(local)
49   mkdirp.sync(path.resolve(pkg, 'node_modules'))
50   fs.writeFileSync(
51     path.join(local, 'package.json'),
52     JSON.stringify(json, null, 2)
53   )
54   process.chdir(pkg)
55 }
56
57 function cleanup () {
58   process.chdir(osenv.tmpdir())
59   rimraf.sync(pkg)
60 }