Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Add ping command #5788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/npm.js
Expand Up @@ -141,6 +141,7 @@ var commandCache = {}
, "prefix"
, "bin"
, "whoami"
, "ping"

, "test"
, "stop"
Expand Down
19 changes: 19 additions & 0 deletions lib/ping.js
@@ -0,0 +1,19 @@

var npm = require("./npm.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"))

npm.registry.ping(registry, function (er, pong) {
cb(er, er ? null : pong)
})
}