summaryrefslogtreecommitdiff
path: root/deps/npm/lib/npm.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/npm.js')
-rw-r--r--deps/npm/lib/npm.js54
1 files changed, 30 insertions, 24 deletions
diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js
index 2db21e34de..de68393d39 100644
--- a/deps/npm/lib/npm.js
+++ b/deps/npm/lib/npm.js
@@ -17,6 +17,8 @@ require("path").SPLIT_CHAR = process.platform === "win32" ? "\\" : "/"
var EventEmitter = require("events").EventEmitter
, npm = module.exports = new EventEmitter
, config = require("./config.js")
+ , set = require("./utils/set.js")
+ , get = require("./utils/get.js")
, ini = require("./utils/ini.js")
, log = require("./utils/log.js")
, fs = require("graceful-fs")
@@ -25,28 +27,11 @@ var EventEmitter = require("events").EventEmitter
, which = require("which")
, semver = require("semver")
, findPrefix = require("./utils/find-prefix.js")
- , getUid = require("uid-number")
- , mkdirp = require("mkdirp")
+ , getUid = require("./utils/uid-number.js")
+ , mkdir = require("./utils/mkdir-p.js")
, slide = require("slide")
, chain = slide.chain
-// /usr/local is often a read-only fs, which is not
-// well handled by node or mkdirp. Just double-check
-// in the case of errors when making the prefix dirs.
-function mkdir (p, cb) {
- mkdirp(p, function (er, made) {
- // it could be that we couldn't create it, because it
- // already exists, and is on a read-only fs.
- if (er) {
- return fs.stat(p, function (er2, st) {
- if (er2 || !st.isDirectory()) return cb(er)
- return cb(null, made)
- })
- }
- return cb(er, made)
- })
-}
-
npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}
@@ -55,7 +40,30 @@ npm.EJSONPARSE = {}
npm.EISGIT = {}
npm.ECYCLE = {}
npm.ENOTSUP = {}
-npm.EBADPLATFORM = {}
+
+// HACK for windows
+if (process.platform === "win32") {
+ // stub in unavailable methods from process and fs binding
+ if (!process.getuid) process.getuid = function() {}
+ if (!process.getgid) process.getgid = function() {}
+ var fsBinding = process.binding("fs")
+ if (!fsBinding.chown) fsBinding.chown = function() {
+ var cb = arguments[arguments.length - 1]
+ if (typeof cb == "function") cb()
+ }
+
+ // patch rename/renameSync, but this should really be fixed in node
+ var _fsRename = fs.rename
+ , _fsPathPatch
+ _fsPathPatch = function(p) {
+ return p && p.replace(/\\/g, "/") || p;
+ }
+ fs.rename = function(p1, p2) {
+ arguments[0] = _fsPathPatch(p1)
+ arguments[1] = _fsPathPatch(p2)
+ return _fsRename.apply(fs, arguments);
+ }
+}
try {
// startup, ok to do this synchronously
@@ -104,7 +112,6 @@ var commandCache = {}
, "unstar": "star" // same function
, "apihelp" : "help"
, "login": "adduser"
- , "add-user": "adduser"
}
, aliasNames = Object.keys(aliases)
@@ -131,7 +138,6 @@ var commandCache = {}
, "unpublish"
, "owner"
, "deprecate"
- , "shrinkwrap"
, "help"
, "help-search"
@@ -303,7 +309,7 @@ function loadPrefix (npm, conf, cb) {
})
// the prefix MUST exist, or else nothing works.
if (!npm.config.get("global")) {
- mkdir(p, next)
+ mkdir(p, npm.modes.exec, null, null, true, next)
} else {
next(er)
}
@@ -316,7 +322,7 @@ function loadPrefix (npm, conf, cb) {
, enumerable : true
})
// the prefix MUST exist, or else nothing works.
- mkdir(gp, next)
+ mkdir(gp, npm.modes.exec, null, null, true, next)
})
var i = 2