Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ping.js « lib « npm « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a86150508d26788fa9e5b06e55fdcb28a5003049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var npm = require('./npm.js')
var output = require('./utils/output.js')

module.exports = ping

ping.usage = 'npm ping\nping registry'

function ping (args, silent, cb) {
  if (typeof cb !== 'function') {
    cb = silent
    silent = false
  }
  var registry = npm.config.get('registry')
  if (!registry) return cb(new Error('no default registry set'))
  var auth = npm.config.getCredentialsByURI(registry)

  npm.registry.ping(registry, {auth: auth}, function (er, pong) {
    if (!silent) output(JSON.stringify(pong))
    cb(er, er ? null : pong)
  })
}