]> 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-link.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-link.js
1 var exec = require('child_process').exec
2 var fs = require('graceful-fs')
3 var path = require('path')
4 var existsSync = fs.existsSync || path.existsSync
5
6 var mkdirp = require('mkdirp')
7 var osenv = require('osenv')
8 var rimraf = require('rimraf')
9 var test = require('tap').test
10
11 var common = require('../common-tap.js')
12
13 var pkg = path.join(__dirname, 'install-scoped-link')
14 var work = path.join(__dirname, 'install-scoped-link-TEST')
15 var modules = path.join(work, 'node_modules')
16
17 var EXEC_OPTS = { cwd: work }
18
19 var world = 'console.log("hello blrbld")\n'
20
21 var json = {
22   name: '@scoped/package',
23   version: '0.0.0',
24   bin: {
25     hello: './world.js'
26   }
27 }
28
29 test('setup', function (t) {
30   cleanup()
31   mkdirp.sync(pkg)
32   fs.writeFileSync(
33     path.join(pkg, 'package.json'),
34     JSON.stringify(json, null, 2)
35   )
36   fs.writeFileSync(path.join(pkg, 'world.js'), world)
37
38   mkdirp.sync(modules)
39   process.chdir(work)
40
41   t.end()
42 })
43
44 test('installing package with links', function (t) {
45   common.npm(
46     [
47       '--loglevel', 'silent',
48       'install', pkg
49     ],
50     EXEC_OPTS,
51     function (err, code) {
52       t.ifError(err, 'install ran to completion without error')
53       t.notOk(code, 'npm install exited with code 0')
54
55       t.ok(
56         existsSync(path.join(modules, '@scoped', 'package', 'package.json')),
57         'package installed'
58       )
59       t.ok(existsSync(path.join(modules, '.bin')), 'binary link directory exists')
60
61       var hello = path.join(modules, '.bin', 'hello')
62       t.ok(existsSync(hello), 'binary link exists')
63
64       exec('node ' + hello, function (err, stdout, stderr) {
65         t.ifError(err, 'command ran fine')
66         t.notOk(stderr, 'got no error output back')
67         t.equal(stdout, 'hello blrbld\n', 'output was as expected')
68
69         t.end()
70       })
71     }
72   )
73 })
74
75 test('cleanup', function (t) {
76   cleanup()
77   t.end()
78 })
79
80 function cleanup () {
81   process.chdir(osenv.tmpdir())
82   rimraf.sync(work)
83   rimraf.sync(pkg)
84 }