-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig-private.js
83 lines (73 loc) · 1.81 KB
/
config-private.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var fs = require('fs')
var path = require('path')
var test = require('tap').test
var rimraf = require('rimraf')
var mkdirp = require('mkdirp')
var common = require('../common-tap.js')
var pkg = path.resolve(__dirname, 'config-private')
var opts = { cwd: pkg }
test('setup', function (t) {
rimraf.sync(pkg)
mkdirp.sync(pkg)
t.end()
})
test('config get private var (old auth)', function (t) {
common.npm(
[
'config',
'get',
'_auth'
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err)
t.similar(stderr, /sekretz/, 'password blocked on stderr')
t.equal(stdout, '', 'no output')
t.end()
}
)
})
test('config get private var (new auth)', function (t) {
common.npm(
[
'config',
'get',
'//registry.npmjs.org/:_password'
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err)
t.similar(stderr, /sekretz/, 'password blocked on stderr')
t.equal(stdout, '', 'no output')
t.end()
}
)
})
test('config get public var (new username)', function (t) {
var FIXTURE_PATH = path.resolve(pkg, 'fixture_npmrc')
var s = '//registry.lvh.me/:username = wombat\n' +
'//registry.lvh.me/:_password = YmFkIHBhc3N3b3Jk\n' +
'//registry.lvh.me/:email = [email protected]\n'
fs.writeFileSync(FIXTURE_PATH, s, 'ascii')
fs.chmodSync(FIXTURE_PATH, '0444')
common.npm(
[
'config',
'get',
'//registry.lvh.me/:username',
'--userconfig=' + FIXTURE_PATH,
'--registry=http://registry.lvh.me/'
],
opts,
function (err, code, stdout, stderr) {
t.ifError(err)
t.equal(stderr, '', 'stderr is empty')
t.equal(stdout, 'wombat\n', 'got usename is output')
t.end()
}
)
})
test('clean', function (t) {
rimraf.sync(pkg)
t.end()
})