1var fs = require('fs') 2var resolve = require('path').resolve 3 4var mkdirp = require('mkdirp') 5var test = require('tap').test 6 7var common = require('../common-tap.js') 8 9var pkg = resolve(common.pkg, 'package') 10var target = resolve(common.pkg, 'target') 11 12common.pendIfWindows('man pages do not get installed on Windows') 13 14var EXEC_OPTS = { 15 cwd: target 16} 17 18var json = { 19 name: 'install-man', 20 version: '1.2.3', 21 man: [ './install-man.1' ] 22} 23 24test('setup', function (t) { 25 mkdirp.sync(pkg) 26 // make sure it installs locally 27 mkdirp.sync(resolve(target, 'node_modules')) 28 fs.writeFileSync( 29 resolve(pkg, 'package.json'), 30 JSON.stringify(json, null, 2) + '\n' 31 ) 32 fs.writeFileSync(resolve(pkg, 'install-man.1'), 'THIS IS A MANPAGE\n') 33 t.end() 34}) 35 36test('install man page', function (t) { 37 common.npm( 38 [ 39 'install', 40 '--prefix', target, 41 '--global', 42 pkg 43 ], 44 EXEC_OPTS, 45 function (err, code, stdout, stderr) { 46 t.ifError(err, 'npm command ran from test') 47 t.equals(code, 0, 'install exited with success (0)') 48 t.ok(stdout, 'output indicating success') 49 t.ok( 50 fs.existsSync(resolve(target, 'share', 'man', 'man1', 'install-man.1')), 51 'man page link was created' 52 ) 53 54 t.end() 55 } 56 ) 57}) 58