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-03-22 04:03:40 +0300
committerisaacs <i@izs.me>2011-03-22 04:03:40 +0300
commit6d7c5d7b47b93b8ae5583f031a628e5e578442ff (patch)
tree90700a5eb46aa67d5579154634766bbf7ae4d4ac
parentf8546b4627728a34b163ccb4cd82d216519da8e5 (diff)
Don't put node_modules directly in prefix. put it in prefix/lib
-rw-r--r--lib/build.js3
-rw-r--r--lib/install.js4
-rw-r--r--lib/link.js6
-rw-r--r--lib/ls.js1
-rw-r--r--lib/utils/completion/installed-shallow.js2
-rw-r--r--npm.js8
6 files changed, 17 insertions, 7 deletions
diff --git a/lib/build.js b/lib/build.js
index 9d2d14117..f42c5a194 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -48,7 +48,8 @@ function linkStuff (pkg, folder, global, cb) {
// then bins are in {prefix}/bin
// otherwise, then bins are in folder/../.bin
var parent = path.dirname(folder)
- , gnm = global && path.resolve(npm.config.get("prefix"), "node_modules")
+ , gnm = global && path.resolve(npm.config.get("prefix")
+ , "lib", "node_modules")
, top = gnm === parent
log.verbose([global, gnm, top, parent], "linkStuff")
diff --git a/lib/install.js b/lib/install.js
index 1522b4639..b39e6180e 100644
--- a/lib/install.js
+++ b/lib/install.js
@@ -105,7 +105,8 @@ install.completion = function (opts, cb) {
// if it has a slash, then it's gotta be a folder
// if it starts with https?://, then just give up, because it's a url
// for now, not yet implemented.
- return cb()
+ var registry = require("./utils/npm-registry-client")
+ return registry.get("/-/short", cb)
}
var npm = require("../npm")
@@ -124,6 +125,7 @@ var npm = require("../npm")
function install (args, cb) {
var where = npm.prefix
+ if (npm.config.get("global")) where = path.resolve(where, "lib")
// internal api: install(what, where, cb)
if (arguments.length === 3) {
diff --git a/lib/link.js b/lib/link.js
index e86952731..1ce62827a 100644
--- a/lib/link.js
+++ b/lib/link.js
@@ -19,7 +19,7 @@ link.usage = "npm link (in package dir)"
+ "\nnpm link <pkg> (link global into local)"
link.completion = function (opts, cb) {
- var dir = path.join(npm.config.get("prefix"), "node_modules")
+ var dir = path.join(npm.config.get("prefix"), "lib", "node_modules")
fs.readdir(dir, function (er, files) {
cb(er, files.filter(function (f) {
return f.charAt(0) !== "."
@@ -38,7 +38,7 @@ function link (args, cb) {
function linkInstall (pkgs, cb) {
var gp = npm.config.get("prefix")
asyncMap(pkgs, function (pkg, cb) {
- var pp = path.resolve(gp, "node_modules", pkg)
+ var pp = path.resolve(gp, "lib", "node_modules", pkg)
, rp = null
, target = path.resolve(npm.dir, pkg)
fs.lstat(pp, function (er, st) {
@@ -75,7 +75,7 @@ function linkPkg (folder, cb) {
, readJson = require("./utils/read-json")
readJson(path.resolve(folder, "package.json"), function (er, d) {
if (er) return cb(er)
- var target = path.resolve(gp, "node_modules", d.name)
+ var target = path.resolve(gp, "lib", "node_modules", d.name)
rm(target, function (er) {
if (er) return cb(er)
symlink(me, target, function (er) {
diff --git a/lib/ls.js b/lib/ls.js
index e2dac9a6a..7ecf09e67 100644
--- a/lib/ls.js
+++ b/lib/ls.js
@@ -22,6 +22,7 @@ function ls (args, cb) {
log.warn("ls doesn't take args. Try the 'search' command")
}
var dir = npm.prefix
+ if (npm.config.get("global")) dir = path.resolve(dir, "lib")
readInstalled(dir, function (er, data) {
if (er) return cb(er)
var long = npm.config.get("long")
diff --git a/lib/utils/completion/installed-shallow.js b/lib/utils/completion/installed-shallow.js
index 0a3343d8d..f5139cd95 100644
--- a/lib/utils/completion/installed-shallow.js
+++ b/lib/utils/completion/installed-shallow.js
@@ -15,7 +15,7 @@ function installedShallow (opts, filter, cb) {
var local
, global
, localDir = npm.dir
- , globalDir = path.join(npm.config.get("prefix"), "node_modules")
+ , globalDir = path.join(npm.config.get("prefix"), "lib", "node_modules")
if (npm.config.get("global")) local = [], next()
else fs.readdir(localDir, function (er, pkgs) {
local = (pkgs || []).filter(function (p) {
diff --git a/npm.js b/npm.js
index e54ec31bf..901f02432 100644
--- a/npm.js
+++ b/npm.js
@@ -213,7 +213,13 @@ npm.config =
}
Object.defineProperty(npm, "dir",
- { get : function () { return path.resolve(npm.prefix, "node_modules") }
+ { get : function () {
+ if (npm.config.get("global")) {
+ return path.resolve(npm.prefix, "lib", "node_modules")
+ } else {
+ return path.resolve(npm.prefix, "node_modules")
+ }
+ }
, enumerable : true
})