1var fs = require('graceful-fs') 2var path = require('path') 3 4var mr = require('npm-registry-mock') 5var test = require('tap').test 6 7var common = require('../common-tap.js') 8 9var pkg = common.pkg 10 11function hasOnlyAscii (s) { 12 return /^[\000-\177]*$/.test(s) 13} 14 15var EXEC_OPTS = { cwd: pkg } 16 17var json = { 18 name: 'install-cli', 19 description: 'fixture', 20 version: '0.0.1', 21 dependencies: { 22 read: '1.0.5' 23 } 24} 25 26test('setup', function (t) { 27 fs.writeFileSync( 28 path.join(pkg, 'package.json'), 29 JSON.stringify(json, null, 2) 30 ) 31 32 mr({ port: common.port }, function (er, s) { 33 t.parent.teardown(() => s.close()) 34 t.end() 35 }) 36}) 37 38test('does not use unicode with --unicode false', function (t) { 39 common.npm( 40 [ 41 '--unicode', 'false', 42 '--registry', common.registry, 43 '--loglevel', 'silent', 44 'install', 'optimist' 45 ], 46 EXEC_OPTS, 47 function (err, code, stdout) { 48 t.ifError(err, 'install package read without unicode success') 49 t.notOk(code, 'npm install exited with code 0') 50 t.ifError(err, 'npm install ran without issue') 51 t.ok(stdout, 'got some output') 52 t.ok(hasOnlyAscii(stdout), 'only ASCII in install output') 53 54 t.end() 55 } 56 ) 57}) 58