]> 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-cli-unicode.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-cli-unicode.js
1 var fs = require('graceful-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 common = require('../common-tap.js')
11 var server
12
13 var pkg = path.resolve(__dirname, 'install-cli-unicode')
14
15 function hasOnlyAscii (s) {
16   return /^[\000-\177]*$/.test(s)
17 }
18
19 var EXEC_OPTS = { cwd: pkg }
20
21 var json = {
22   name: 'install-cli',
23   description: 'fixture',
24   version: '0.0.1',
25   dependencies: {
26     read: '1.0.5'
27   }
28 }
29
30 test('setup', function (t) {
31   rimraf.sync(pkg)
32   mkdirp.sync(pkg)
33   fs.writeFileSync(
34     path.join(pkg, 'package.json'),
35     JSON.stringify(json, null, 2)
36   )
37
38   mr({ port: common.port }, function (er, s) {
39     server = s
40     t.end()
41   })
42 })
43
44 test('does not use unicode with --unicode false', function (t) {
45   common.npm(
46     [
47       '--unicode', 'false',
48       '--registry', common.registry,
49       '--loglevel', 'silent',
50       'install', 'optimist'
51     ],
52     EXEC_OPTS,
53     function (err, code, stdout) {
54       t.ifError(err, 'install package read without unicode success')
55       t.notOk(code, 'npm install exited with code 0')
56       t.ifError(err, 'npm install ran without issue')
57       t.ok(stdout, 'got some output')
58       t.ok(hasOnlyAscii(stdout), 'only ASCII in install output')
59
60       t.end()
61     }
62   )
63 })
64
65 test('cleanup', function (t) {
66   server.close()
67   process.chdir(osenv.tmpdir())
68   rimraf.sync(pkg)
69
70   t.end()
71 })