1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var mr = require('npm-registry-mock')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')
var pkg = common.pkg
var outfile = path.join(pkg, '_npmrc')
var opts = { cwd: pkg }
var contents = `foo=boo
//localhost:${common.port}/:_authToken=glarb
`
function mocks (server) {
server.delete('/-/user/token/glarb')
.reply(200, {})
}
test('setup', function (t) {
cleanup()
setup()
t.end()
})
test('npm logout', function (t) {
mr({ port: common.port, plugin: mocks }, function (err, s) {
if (err) throw err
common.npm(
[
'logout',
'--registry', common.registry,
'--loglevel', 'silent',
'--userconfig', outfile
],
opts,
function (err, code) {
t.ifError(err, 'no error output')
t.notOk(code, 'exited OK')
var config = fs.readFileSync(outfile, 'utf8')
t.notMatch(config, /localhost/, 'creds gone')
s.close()
t.end()
}
)
})
})
test('cleanup', function (t) {
cleanup()
t.end()
})
function setup () {
mkdirp.sync(pkg)
fs.writeFileSync(outfile, contents)
}
function cleanup () {
rimraf.sync(pkg)
}
|