const npmConfig = require('./config/figgy-config.js')
const fetch = require('libnpm/fetch')
const figgyPudding = require('figgy-pudding')
const log = require('npmlog')
const npm = require('./npm.js')
const output = require('./utils/output.js')
const PingConfig = figgyPudding({
ping.usage = 'npm ping\nping registry'
function ping (args, silent, cb) {
if (typeof cb !== 'function') {
const opts = PingConfig(npmConfig())
const registry = opts.registry
log.notice('PING', registry)
return fetch('/-/ping?write=true', opts).then(
res => res.json().catch(() => ({}))
const time = Date.now() - start
log.notice('PONG', `${time / 1000}ms`)
if (npm.config.get('json')) {
} else if (Object.keys(details).length) {
log.notice('PONG', `${JSON.stringify(details, null, 2)}`)