Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
registry: default to registry.npmjs.org if option is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Dec 5, 2016
1 parent 3f3cd37 commit 7db952c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/registry/pick-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,5 @@ function pickRegistry (spec, opts, cb) {
registry = opts.registry
}

if (registry) {
cb(null, registry)
} else {
cb(new Error('registry option is required'))
}
cb(null, registry || 'https://registry.npmjs.org')
}
11 changes: 11 additions & 0 deletions test/manifest.registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ test('uses scope opt for registry lookup', function (t) {
})
})

test('defaults to registry.npmjs.org if no option given', function (t) {
var server = nock('https://registry.npmjs.org')

server.get('/foo/1.2.3').once().reply(200, PKG)
manifest('foo@1.2.3', { registry: undefined }, function (err, pkg) {
if (err) { throw err }
t.deepEqual(pkg, PKG, 'used npm registry')
t.end()
})
})

test('supports scoped auth', function (t) {
var TOKEN = 'deadbeef'
var opts = {
Expand Down

0 comments on commit 7db952c

Please sign in to comment.