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/npm.js
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-02-08 03:50:00 +0300
committerisaacs <i@izs.me>2011-02-08 04:09:08 +0300
commita997b3491059a55a04353c904c01e2b891d000d8 (patch)
tree453c18361a9dc1433eded4ae556e5b5757351045 /npm.js
parent18166ae8bfeeb90e5136439b72b061c88fb6a5d1 (diff)
Check for sudo being ok based on node version
Diffstat (limited to 'npm.js')
-rw-r--r--npm.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/npm.js b/npm.js
index e9a824634..71f54d46d 100644
--- a/npm.js
+++ b/npm.js
@@ -20,6 +20,7 @@ var EventEmitter = require("events").EventEmitter
, path = require("path")
, abbrev = require("./lib/utils/abbrev")
, which = require("./lib/utils/which")
+ , semver = require("./lib/utils/semver")
npm.commands = {}
npm.ELIFECYCLE = {}
@@ -196,4 +197,16 @@ Object.defineProperty(npm, "tmp",
})
// platforms without uid/gid support are assumed to be in unsafe-perm mode.
-if (!process.getuid) npm.config.set("unsafe-perm", true)
+var sudoOk = !semver.lt(process.version, '0.3.5')
+if (!process.getuid || !sudoOk) {
+ npm.config.set("unsafe-perm", true)
+}
+if (process.getuid && process.getuid() === 0 && !sudoOk) {
+ process.nextTick(function () {
+ log([""
+ ,"Please upgrade to node 0.3.5 or higher"
+ ,"if you are going to be running npm as root."
+ ,"It is not safe otherwise."
+ ,""].join("\n"), "", "error")
+ })
+}