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
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-10-12 21:17:48 +0400
committerisaacs <i@izs.me>2011-10-12 21:17:48 +0400
commit9fa5ca2b66a9923564d8a4ff8c2381d84587560b (patch)
treea5fcc6ce695d6279799ec182d7d04b87421f2d7f /lib
parentd753758a8d1d1525b8cb879c8de4674abb8d6975 (diff)
Explicitly inject builtinconfig into any npm install
Diffstat (limited to 'lib')
-rw-r--r--lib/build.js7
-rw-r--r--lib/utils/ini.js27
2 files changed, 18 insertions, 16 deletions
diff --git a/lib/build.js b/lib/build.js
index c3a469633..73050454c 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -61,11 +61,10 @@ function build_ (global, didPre, didRB) { return function (folder, cb) {
}}
function writeBuiltinConf (folder, cb) {
- // if overwriting *this* instance of npm, then write the default conf,
- // because otherwise we just lost overwrote the current folder.
- if (folder !== path.resolve(__dirname, "..")) return cb()
+ // the builtin config is "sticky". Any time npm installs itself,
+ // it puts its builtin config file there, as well.
var ini = require("./utils/ini.js")
- ini.save("builtin", cb)
+ ini.saveConfig("builtin", path.resolve(folder, "npmrc"), cb)
}
function linkStuff (pkg, folder, global, didRB, cb) {
diff --git a/lib/utils/ini.js b/lib/utils/ini.js
index 342e1271c..95fa5a5cc 100644
--- a/lib/utils/ini.js
+++ b/lib/utils/ini.js
@@ -19,6 +19,7 @@
exports.resolveConfigs = resolveConfigs
exports.save = save
+exports.saveConfig = saveConfig
exports.del = del
exports.get = get
exports.set = set
@@ -239,18 +240,20 @@ function save (which, cb) {
})
}
-function saveConfig (which, cb) {
- var file
- switch (which) {
- case "builtin":
- file = path.resolve(__dirname, "../../npmrc")
- break
- case "global":
- file = configList.get("globalconfig")
- break
- default:
- file = configList.get("userconfig")
- which = "user"
+function saveConfig (which, file, cb) {
+ if (typeof file === "function") cb = file, file = null
+ if (!file) {
+ switch (which) {
+ case "builtin":
+ file = path.resolve(__dirname, "../../npmrc")
+ break
+ case "global":
+ file = configList.get("globalconfig")
+ break
+ default:
+ file = configList.get("userconfig")
+ which = "user"
+ }
}
saveConfigfile