]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/scripts-whitespace-windows.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / scripts-whitespace-windows.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')
10
11 var pkg = path.resolve(__dirname, 'scripts-whitespace-windows')
12 var tmp = path.resolve(pkg, 'tmp')
13 var cache = path.resolve(pkg, 'cache')
14 var dep = path.resolve(pkg, 'dep')
15
16 var EXEC_OPTS = { cwd: pkg }
17
18 var json = {
19   name: 'scripts-whitespace-windows',
20   version: '1.0.0',
21   description: 'a test',
22   repository: 'git://github.com/robertkowalski/bogus',
23   scripts: {
24     foo: 'foo --title \"Analysis of\" --recurse -d report src'
25   },
26   dependencies: {
27     'scripts-whitespace-windows-dep': '0.0.1'
28   },
29   license: 'WTFPL'
30 }
31
32 var dependency = {
33   name: 'scripts-whitespace-windows-dep',
34   version: '0.0.1',
35   bin: [ 'bin/foo' ]
36 }
37
38 var foo = function () {/*
39 #!/usr/bin/env node
40
41 if (process.argv.length === 8)
42   console.log('npm-test-fine')
43 */}.toString().split('\n').slice(1, -1).join('\n')
44
45 test('setup', function (t) {
46   cleanup()
47   mkdirp.sync(tmp)
48   fs.writeFileSync(
49     path.join(pkg, 'package.json'),
50     JSON.stringify(json, null, 2)
51   )
52   fs.writeFileSync(
53     path.join(pkg, 'README.md'),
54     "### THAT'S RIGHT\n"
55   )
56
57   mkdirp.sync(path.join(dep, 'bin'))
58   fs.writeFileSync(
59     path.join(dep, 'package.json'),
60     JSON.stringify(dependency, null, 2)
61   )
62   fs.writeFileSync(path.join(dep, 'bin', 'foo'), foo)
63
64   common.npm(['i', dep], {
65     cwd: pkg,
66     env: {
67       npm_config_cache: cache,
68       npm_config_tmp: tmp,
69       npm_config_prefix: pkg,
70       npm_config_global: 'false'
71     }
72   }, function (err, code, stdout, stderr) {
73     t.ifErr(err, 'npm i ' + dep + ' finished without error')
74     t.equal(code, 0, 'npm i ' + dep + ' exited ok')
75     t.notOk(stderr, 'no output stderr')
76     t.end()
77   })
78 })
79
80 test('test', function (t) {
81   common.npm(['run', 'foo'], EXEC_OPTS, function (err, code, stdout, stderr) {
82     stderr = stderr.trim()
83     if (stderr) console.error(stderr)
84     t.ifErr(err, 'npm run finished without error')
85     t.equal(code, 0, 'npm run exited ok')
86     t.notOk(stderr, 'no output stderr: ' + stderr)
87     stdout = stdout.trim()
88     t.ok(/npm-test-fine/.test(stdout))
89     t.end()
90   })
91 })
92
93 test('cleanup', function (t) {
94   cleanup()
95   t.end()
96 })
97
98 function cleanup () {
99   process.chdir(osenv.tmpdir())
100   rimraf.sync(pkg)
101 }
102