Permalink
Browse files

Don't put node_modules directly in prefix. put it in prefix/lib

  • Loading branch information...
1 parent f8546b4 commit 6d7c5d7b47b93b8ae5583f031a628e5e578442ff @isaacs isaacs committed Mar 22, 2011
Showing with 17 additions and 7 deletions.
  1. +2 −1 lib/build.js
  2. +3 −1 lib/install.js
  3. +3 −3 lib/link.js
  4. +1 −0 lib/ls.js
  5. +1 −1 lib/utils/completion/installed-shallow.js
  6. +7 −1 npm.js
View
@@ -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")
View
@@ -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) {
View
@@ -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) {
View
@@ -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")
@@ -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) {
View
8 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
})

0 comments on commit 6d7c5d7

Please sign in to comment.