diff options
Diffstat (limited to 'deps/npm/lib/utils/completion/users.js')
-rw-r--r-- | deps/npm/lib/utils/completion/users.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/completion/users.js b/deps/npm/lib/utils/completion/users.js new file mode 100644 index 0000000000..f77312c94e --- /dev/null +++ b/deps/npm/lib/utils/completion/users.js @@ -0,0 +1,22 @@ + +module.exports = users + +var registry = require("../npm-registry-client/index.js") + , containsSingleMatch = require("./contains-single-match.js") + , getCompletions = require("./get-completions.js") + , log = require("../log.js") + +function users (args, index, cb) { + var name = (args.length + 1 === index) ? args[args.length - 1] : "" + if (name === undefined) name = "" + // use up-to 1 day stale cache. doesn't change much + log.warn("About to fetch", "users completion") + registry.get("/-/users", null, 24*60*60, function (er, d) { + log.warn(d, "userdata") + log.warn(name, "name") + if (er) return cb(er) + var remoteList = Object.keys(d) + , simpleMatches = getCompletions(name, remoteList) + return cb(null, simpleMatches) + }) +} |