-
Notifications
You must be signed in to change notification settings - Fork 37
/
config.js
70 lines (59 loc) · 1.92 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var path = require('path')
var rc = require('rc')
var optimist = require('optimist')
var toCC = require('to-camel-case')
var osenv = require('osenv')
var home = osenv.home()
var tmp = osenv.tmpdir()
module.exports = (function () {
// *** vvv Copied this stuff out of npmconf **********************
var uidOrPid = process.getuid ? process.getuid() : process.pid
if (home) process.env.HOME = home
else home = path.resolve(temp, "npm-" + uidOrPid)
var cacheExtra = process.platform === "win32" ? "npm-cache" : ".npm"
var cacheRoot = process.platform === "win32" && process.env.APPDATA || home
var cache = path.resolve(cacheRoot, cacheExtra)
// *** ^^^ Copied this stuff out of npmconf **********************
var config = rc('npmd', {
dbPath: path.join(process.env.HOME, '.npmd'),
debug: true,
sync: false,
encoding: 'json',
registry: 'http://isaacs.iriscouch.com/registry',
cache: cache,
"user-agent" : "node/" + process.version
+ ' ' + process.platform
+ ' ' + process.arch,
prefix: (
process.env.PREFIX ||
( process.platform === 'win32' ? path.dirname(process.execPath)
: path.dirname(path.dirname(process.execPath)))
),
port: 5656
},
optimist
.alias('g', 'global')
.alias('f', 'force')
.alias('D', 'saveDev')
.alias('S', 'save')
.boolean('global')
.boolean('online')
.boolean('offline')
.boolean('save-dev')
.boolean('saveDev')
.boolean('save-peer')
.boolean('savePeer')
.boolean('save')
.argv
)
config.bin = config.bin ||
( config.global ? path.join(config.prefix, 'bin')
: path.join(config.path || process.cwd(), 'node_modules', '.bin'))
if(!config.path && config.global)
config.path = config.prefix
for(var k in config)
config[toCC(k)] = config[k]
if(config.showConfig)
console.log(JSON.stringify(config, null, 2))
return config
})()