diff options
-rw-r--r-- | lib/utils/load-package-defaults.js | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/utils/load-package-defaults.js b/lib/utils/load-package-defaults.js index ece20e25b..a90776d1d 100644 --- a/lib/utils/load-package-defaults.js +++ b/lib/utils/load-package-defaults.js @@ -24,10 +24,11 @@ function readDefaultMans (pkg, cb) { if (pkg.man || !man) return cb(null, pkg) find(manDir, /\.[0-9]+(\.gz)?$/, function (er, filenames) { if (er) return cb(er) - pkg.man = filenames.map(function (filename) { - var f = path.basename(filename) - return filename.substr(pkgDir.length + 1) - }) + pkg.man = filenames.filter(function(_){return _}) + .map(function (filename) { + var f = path.basename(filename) + return filename.substr(pkgDir.length + 1) + }) cb(null,pkg) }) } @@ -42,10 +43,11 @@ function readDefaultModules (pkg, cb) { pkg.modules = {} find(libDir, /\.(js|node)$/, function (er, filenames) { if (er) return cb(er) - filenames.forEach(function (filename) { + filenames.filter(function(_){return _}).forEach(function (filename) { filename = path.basename(filename, path.extname(filename)) - pkg.modules[filename.substr(libDir.length + 1)] = - filename.substr(pkgDir.length + 1) + var key = filename.substr(libDir.length + 1) + , val = filename.substr(pkgDir.length + 1) + if (key.length && val.length) pkg.modules[key] = val }) return cb(null, pkg) }) @@ -64,7 +66,8 @@ function readDefaultBins (pkg, cb) { filenames.forEach(function (filename) { var key = filename.substr(binDir.length + 1) .replace(/\.(js|node)$/, '') - pkg.bin[key] = filename.substr(pkgDir.length + 1) + , val = filename.substr(pkgDir.length + 1) + if (key.length && val.length) pkg.bin[key] = val }) log.silly(pkg.bin, pkg._id+".bin") cb(null, pkg) |