• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var common = require('../common-tap.js')
2var test = require('tap').test
3var rimraf = require('rimraf')
4var prefix = __filename.replace(/\.js$/, '')
5var rcfile = __filename.replace(/\.js$/, '.npmrc')
6var fs = require('fs')
7var conf = 'prefix = ' + prefix + '\n'
8
9test('setup', function (t) {
10  rimraf.sync(prefix)
11  fs.writeFileSync(rcfile, conf)
12  t.pass('ready')
13  t.end()
14})
15
16test('run command', function (t) {
17  var args = ['prefix', '-g', '--userconfig=' + rcfile]
18  common.npm(args, {env: {}}, function (er, code, so) {
19    if (er) throw er
20    t.notOk(code, 'npm prefix exited with code 0')
21    t.equal(so.trim(), prefix)
22    t.end()
23  })
24})
25
26test('made dir', function (t) {
27  t.ok(fs.statSync(prefix).isDirectory())
28  t.end()
29})
30
31test('cleanup', function (t) {
32  rimraf.sync(prefix)
33  rimraf.sync(rcfile)
34  t.pass('clean')
35  t.end()
36})
37