diff options
author | Michael Nisi <michael.nisi@gmail.com> | 2014-07-24 18:22:55 +0400 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-07-01 12:41:32 +0300 |
commit | 311db70fa3f0a6afd89ce24e5b02ff86dc1c8bb8 (patch) | |
tree | 795a3066cb297cb8fc3a33e40e5ea36668459515 | |
parent | 89741b6f8cbf535952d5d41dd3572e08560ef5f0 (diff) |
npm: Add ping command
Fixes #5750
PR-URL: https://github.com/npm/npm/pull/5788
-rw-r--r-- | lib/npm.js | 1 | ||||
-rw-r--r-- | lib/ping.js | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/npm.js b/lib/npm.js index 180e3d4bf..30a42412d 100644 --- a/lib/npm.js +++ b/lib/npm.js @@ -138,6 +138,7 @@ 'bin', 'whoami', 'dist-tag', + 'ping', 'test', 'stop', diff --git a/lib/ping.js b/lib/ping.js new file mode 100644 index 000000000..9a07d93a5 --- /dev/null +++ b/lib/ping.js @@ -0,0 +1,18 @@ +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) + }) +} |