Permalink
Browse files

Remove modules hash from default-loading

  • Loading branch information...
1 parent 8e14892 commit a7bec5a0383c8dd10e2972aa451161f1dafca67d @isaacs isaacs committed Feb 22, 2011
Showing with 1 addition and 36 deletions.
  1. +1 −36 lib/utils/load-package-defaults.js
@@ -28,7 +28,6 @@ function loadPackageDefaults (pkg, pkgDir, cb) {
asyncMap
( [pkg]
, function (pkg, cb) { log.verbose(pkg._id, "loadDefaults", cb) }
- , readDefaultModules(pkgDir)
, readDefaultBins(pkgDir)
, readDefaultMans(pkgDir)
, readDefaultFiles(pkgDir)
@@ -71,7 +70,7 @@ function objectForEach (obj, fn) {
function readDefaultFiles (pkgDir) { return function (pkg, cb) {
var list = pkg.files = pkg.files || [""]
- ;["directories", "modules", "bin", "man"].forEach(function (k) {
+ ;["directories", "bin", "man"].forEach(function (k) {
objectForEach(pkg[k] || {}, addFile(list))
})
@@ -119,40 +118,6 @@ function readDefaultMans (pkgDir) { return function (pkg, cb) {
})
}}
-// shim ROOT/{name}-{version}/**/*.js to ROOT/.npm/{name}/{version}/{lib}/**/*.js
-function readDefaultModules (pkgDir) { return function (pkg, cb) {
- log.verbose(pkg._id, "readDefaultModules")
- var lib = pkg.directories && pkg.directories.lib || pkg.lib
- , libDir = path.join(pkgDir, lib).replace(/\/+$/, '')
- if (!lib) return cb(null, pkg)
- // create a modules hash from the lib folder.
- pkg.modules = {}
- var cut = pkgDir === "." ? 0 : pkgDir.length + 1
- , libCut = pkgDir === "." ? lib.length - 1 : libDir.length + 1
- find(libDir, function (er, filenames) {
- if (er) return cb(er)
- filenames.filter(function (f) {
- return !f.substr(libCut).match(/(^|\/)\./)
- }).forEach(function (filename) {
- // filename = path.basename(filename, path.extname(filename))
- var key = filename.substr(libCut)
- , val = filename.substr(cut)
- key = key.replace(/\.node$/, ".js")
- if (key.length && val.length) pkg.modules[key] = val
- })
- // require("foo/foo") is dumb, and happens a lot.
- var nameMod = pkg.modules[pkg.name] || pkg.modules[pkg.name+".js"]
- if (!pkg.main
- && !pkg.modules.index
- && !pkg.modules["index.js"]
- && nameMod) {
- pkg.modules["index.js"] = nameMod
- }
- log.silly(pkg.modules, pkg._id+".modules")
- return cb(null, pkg)
- })
-}}
-
function readDefaultBins (pkgDir) { return function (pkg, cb) {
var bin = pkg.directories && pkg.directories.bin
if (pkg.bins) pkg.bin = pkg.bins, delete pkg.bins

0 comments on commit a7bec5a

Please sign in to comment.