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:
authorisaacs <i@izs.me>2011-06-03 04:06:17 +0400
committerisaacs <i@izs.me>2011-06-03 04:06:17 +0400
commit8b54f2c8b680af94084b00759a0e7c6a83bb0b8b (patch)
treec8e2745eaea48e670cf27e3ed3cfe7d03f08f736
parent2552095132236a9e5c56e4deaa197e71eaf8be31 (diff)
Work properly in absence of a HOME environ
-rw-r--r--lib/utils/config-defs.js10
-rw-r--r--lib/utils/npm-registry-client/get.js2
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/utils/config-defs.js b/lib/utils/config-defs.js
index 4758a5b4a..23129df13 100644
--- a/lib/utils/config-defs.js
+++ b/lib/utils/config-defs.js
@@ -41,7 +41,7 @@ Object.defineProperty(exports, "defaults", {get: function () {
// are there others?
, browser : process.platform === "darwin" ? "open" : "google-chrome"
- , cache : path.resolve( process.env.HOME
+ , cache : path.resolve( process.env.HOME || process.env.TMPDIR || "/tmp"
, process.platform === "win32"
? "npm-cache" : ".npm")
, color : true
@@ -91,8 +91,12 @@ Object.defineProperty(exports, "defaults", {get: function () {
, usage : false
, user : "nobody"
, username : ""
- , userconfig : path.resolve( process.env.HOME, ".npmrc")
- , userignorefile : path.resolve( process.env.HOME, ".npmignore" )
+ , userconfig : process.env.HOME
+ ? path.resolve( process.env.HOME, ".npmrc" )
+ : null
+ , userignorefile : process.env.HOME
+ ? path.resolve( process.env.HOME, ".npmignore" )
+ : null
, version : false
, viewer: "man"
, _exit : true
diff --git a/lib/utils/npm-registry-client/get.js b/lib/utils/npm-registry-client/get.js
index b423e7c40..107aea331 100644
--- a/lib/utils/npm-registry-client/get.js
+++ b/lib/utils/npm-registry-client/get.js
@@ -77,7 +77,7 @@ function saveToCache (cache, data, saved) {
}
fs.stat(npm.cache, function (er, st) {
if (er) {
- return fs.stat(process.env.HOME, function (er, st) {
+ return fs.stat(process.env.HOME || "", function (er, st) {
// if this fails, oh well.
if (er) return saved()
cacheStat = st