Skip to content

Commit 3eb3f62

Browse files
isaacsnlf
authored andcommitted
Remove publishConfig option
Note: SemVer Major breaking change This removes the 'publishConfig' option, as it will no longer be used once npm/cli#2066 lands. PR-URL: #36 Credit: @isaacs Close: #36 Reviewed-by: @nlf
1 parent e8617ad commit 3eb3f62

File tree

3 files changed

+4
-47
lines changed

3 files changed

+4
-47
lines changed

index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function regFetch (uri, /* istanbul ignore next */ opts_ = {}) {
2929
}
3030
const registry = opts.registry = (
3131
(opts.spec && pickRegistry(opts.spec, opts)) ||
32-
(opts.publishConfig && opts.publishConfig.registry) ||
3332
opts.registry ||
3433
/* istanbul ignore next */
3534
'https://registry.npmjs.org/'
@@ -151,9 +150,6 @@ function pickRegistry (spec, opts = {}) {
151150
if (!registry && opts.scope)
152151
registry = opts[opts.scope.replace(/^@?/, '@') + ':registry']
153152

154-
if (!registry && opts.publishConfig)
155-
registry = opts.publishConfig.registry
156-
157153
if (!registry)
158154
registry = opts.registry || 'https://registry.npmjs.org/'
159155

@@ -163,7 +159,8 @@ function pickRegistry (spec, opts = {}) {
163159
function getCacheMode (opts) {
164160
return opts.offline ? 'only-if-cached'
165161
: opts.preferOffline ? 'force-cache'
166-
: opts.preferOnline ? 'no-cache' : 'default'
162+
: opts.preferOnline ? 'no-cache'
163+
: 'default'
167164
}
168165

169166
function getHeaders (registry, uri, opts) {

test/check-response.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ test('log the url fetched', async t => {
7171
log: Object.assign({}, silentLog, {
7272
http (header, msg) {
7373
t.equal(header, 'fetch')
74-
t.equal(msg, 'GET 200 http://example.com/foo/bar/baz 0ms')
74+
t.match(msg, /^GET 200 http:\/\/example.com\/foo\/bar\/baz [0-9]+m?s/)
7575
},
7676
}),
7777
})
@@ -92,7 +92,7 @@ test('redact password from log', async t => {
9292
log: Object.assign({}, silentLog, {
9393
http (header, msg) {
9494
t.equal(header, 'fetch')
95-
t.equal(msg, 'GET 200 http://username:***@example.com/foo/bar/baz 0ms')
95+
t.match(msg, /^GET 200 http:\/\/username:\*\*\*@example.com\/foo\/bar\/baz [0-9]+m?s/)
9696
},
9797
}),
9898
})

test/index.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -424,18 +424,6 @@ test('pickRegistry() utility', t => {
424424
'https://my.scoped.registry/here/',
425425
'scope @ is option@l'
426426
)
427-
t.equal(
428-
429-
registry: 'https://my.registry/here/',
430-
scope: '@otherscope',
431-
'@myscope:registry': 'https://my.scoped.registry/here/',
432-
publishConfig: {
433-
registry: 'https://my.package.registry',
434-
},
435-
}),
436-
'https://my.package.registry',
437-
'respects publishConfig setting'
438-
)
439427
t.done()
440428
})
441429

@@ -475,34 +463,6 @@ test('pickRegistry through opts.spec', t => {
475463
))
476464
})
477465

478-
test('pickRegistry through publishConfig', t => {
479-
tnock(t, OPTS.registry)
480-
.get('/pkg')
481-
.reply(200, { source: OPTS.registry })
482-
const publishRegistry = 'https://my.publish.registry'
483-
tnock(t, publishRegistry)
484-
.get('/pkg')
485-
.reply(200, { source: publishRegistry })
486-
487-
return fetch.json('/pkg', {
488-
...OPTS,
489-
publishConfig: {},
490-
}).then(json => t.equal(
491-
json.source,
492-
OPTS.registry,
493-
'request made to default registry when publishConfig specifies no registry'
494-
)).then(() => fetch.json('/pkg', {
495-
...OPTS,
496-
publishConfig: {
497-
registry: publishRegistry,
498-
},
499-
}).then(json => t.equal(
500-
json.source,
501-
publishRegistry,
502-
'request made to publishConfig.registry when one is specified'
503-
)))
504-
})
505-
506466
test('log warning header info', t => {
507467
tnock(t, OPTS.registry)
508468
.get('/hello')

0 commit comments

Comments
 (0)