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

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/npm-registry-client/index.js')
-rw-r--r--node_modules/npm-registry-client/index.js35
1 files changed, 29 insertions, 6 deletions
diff --git a/node_modules/npm-registry-client/index.js b/node_modules/npm-registry-client/index.js
index 801d00f8e..6ea288b0a 100644
--- a/node_modules/npm-registry-client/index.js
+++ b/node_modules/npm-registry-client/index.js
@@ -46,11 +46,34 @@ function RegClient (config) {
this.log = this.config.log || npmlog
delete this.config.log
+
+ var client = this
+ fs.readdirSync(join(__dirname, "lib")).forEach(function (f) {
+ var entry = join(__dirname, "lib", f)
+
+ // lib/group-name/operation.js -> client.groupName.operation
+ var stat = fs.statSync(entry)
+ if (stat.isDirectory()) {
+ var groupName = f.replace(/-([a-z])/, dashToCamel)
+ fs.readdirSync(entry).forEach(function (f) {
+ if (!f.match(/\.js$/)) return
+
+ if (!client[groupName]) {
+ // keep client.groupName.operation from stomping client.operation
+ client[groupName] = Object.create(client)
+ }
+ var name = f.replace(/\.js$/, "").replace(/-([a-z])/, dashToCamel)
+ client[groupName][name] = require(join(entry, f))
+ })
+ return
+ }
+
+ if (!f.match(/\.js$/)) return
+ var name = f.replace(/\.js$/, "").replace(/-([a-z])/, dashToCamel)
+ client[name] = require(entry)
+ })
}
-fs.readdirSync(join(__dirname, "lib")).forEach(function (f) {
- if (!f.match(/\.js$/)) return
- var name = f.replace(/\.js$/, "")
- .replace(/-([a-z])/, function (_, l) { return l.toUpperCase() })
- RegClient.prototype[name] = require(join(__dirname, "lib", f))
-})
+function dashToCamel (_, l) {
+ return l.toUpperCase()
+}