]> 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-at-locally.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-at-locally.js
1 var fs = require('graceful-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
11 var pkg = path.join(__dirname, 'install-at-locally')
12
13 var EXEC_OPTS = { cwd: pkg }
14
15 var json = {
16   name: 'install-at-locally',
17   version: '0.0.0'
18 }
19
20 test('setup', function (t) {
21   cleanup()
22   t.end()
23 })
24
25 test('\'npm install ./package@1.2.3\' should install local pkg', function (t) {
26   var target = './package@1.2.3'
27   setup(target)
28   common.npm(['install', target], EXEC_OPTS, function (err, code) {
29     var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
30     t.ifError(err, 'install local package successful')
31     t.equal(code, 0, 'npm install exited with code')
32     t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
33     t.end()
34   })
35 })
36
37 test('\'npm install install/at/locally@./package@1.2.3\' should install local pkg', function (t) {
38   var target = 'install/at/locally@./package@1.2.3'
39   setup(target)
40   common.npm(['install', target], EXEC_OPTS, function (err, code) {
41     var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
42     t.ifError(err, 'install local package in explicit directory successful')
43     t.equal(code, 0, 'npm install exited with code')
44     t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
45     t.end()
46   })
47 })
48
49 test('cleanup', function (t) {
50   cleanup()
51   t.end()
52 })
53
54 function cleanup () {
55   process.chdir(osenv.tmpdir())
56   rimraf.sync(pkg)
57 }
58
59 function setup (target) {
60   cleanup()
61   var root = path.resolve(pkg, target)
62   mkdirp.sync(root)
63   fs.writeFileSync(
64     path.join(root, 'package.json'),
65     JSON.stringify(json, null, 2)
66   )
67   mkdirp.sync(path.resolve(pkg, 'node_modules'))
68   process.chdir(pkg)
69 }