]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/peer-deps-without-package-json.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / peer-deps-without-package-json.js
1 var fs = require('fs')
2 var path = require('path')
3
4 var mkdirp = require('mkdirp')
5 var mr = require('npm-registry-mock')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
9
10 var npm = require('../../')
11 var common = require('../common-tap.js')
12
13 var pkg = path.resolve(__dirname, 'peer-deps-without-package-json')
14 var cache = path.resolve(pkg, 'cache')
15 var nodeModules = path.resolve(pkg, 'node_modules')
16
17 var fileJS = function () {
18 /**package
19 * { "name": "npm-test-peer-deps-file"
20 * , "main": "index.js"
21 * , "version": "1.2.3"
22 * , "description":"No package.json in sight!"
23 * , "peerDependencies": { "underscore": "1.3.1" }
24 * , "dependencies": { "mkdirp": "0.3.5" }
25 * }
26 **/
27
28   module.exports = 'I\'m just a lonely index, naked as the day I was born.'
29 }.toString().split('\n').slice(1, -1).join('\n')
30
31 test('setup', function (t) {
32   t.comment('test for https://github.com/npm/npm/issues/3049')
33   cleanup()
34   mkdirp.sync(cache)
35   mkdirp.sync(nodeModules)
36   fs.writeFileSync(path.join(pkg, 'file-js.js'), fileJS)
37   process.chdir(pkg)
38
39   t.end()
40 })
41
42 test('installing a peerDeps-using package without package.json', function (t) {
43   var customMocks = {
44     'get': {
45       '/ok.js': [200, path.join(pkg, 'file-js.js')]
46     }
47   }
48   mr({port: common.port, mocks: customMocks}, function (err, s) {
49     t.ifError(err, 'mock registry booted')
50     npm.load({
51       registry: common.registry,
52       cache: cache
53     }, function () {
54       npm.install(common.registry + '/ok.js', function (err) {
55         t.ifError(err, 'installed ok.js')
56
57         t.ok(
58           fs.existsSync(path.join(nodeModules, 'npm-test-peer-deps-file')),
59           'passive peer dep installed'
60         )
61         t.ok(
62           fs.existsSync(path.join(nodeModules, 'underscore')),
63           'underscore installed'
64         )
65
66         t.end()
67         s.close() // shutdown mock registry.
68       })
69     })
70   })
71 })
72
73 test('cleanup', function (t) {
74   cleanup()
75   t.end()
76 })
77
78 function cleanup () {
79   process.chdir(osenv.tmpdir())
80   rimraf.sync(pkg)
81 }