Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Closes GH-739 Don't default directories.

  • Loading branch information...
commit dbf5e805af54be8b111726676f69dc4caea81eb1 1 parent bc7cef1
isaacs isaacs authored
Showing with 7 additions and 35 deletions.
  1. +7 −35 lib/utils/load-package-defaults.js
42 lib/utils/load-package-defaults.js
View
@@ -18,18 +18,13 @@ function loadPackageDefaults (pkg, pkgDir, cb) {
if (pkg._defaultsLoaded) return cb(null, pkg)
- readDefaultDirs(pkgDir)(pkg, function (er) {
- if (er) return cb(er)
- if (pkg._defaultsLoaded) return cb(null, pkg)
- asyncMap
- ( [pkg]
- , function (pkg, cb) { log.verbose(pkg._id, "loadDefaults", cb) }
- , readDefaultBins(pkgDir)
- , readDefaultMans(pkgDir)
- , function (pkg, cb) { pkg._defaultsLoaded = true ; cb() }
- , function (er) { cb(er, pkg) }
- )
- })
+ pkg._defaultsLoaded = true
+ asyncMap
+ ( [pkg]
+ , function (pkg, cb) { log.verbose(pkg._id, "loadDefaults", cb) }
+ , readDefaultBins(pkgDir)
+ , readDefaultMans(pkgDir)
+ , function (er) { cb(er, pkg) } )
}
function addFile (list, f) {
@@ -62,28 +57,6 @@ function objectForEach (obj, fn) {
})
}
-function readDefaultDirs (pkgDir) { return function (pkg, cb) {
- if (pkg.directories && typeof pkg.directories !== "object"
- || Array.isArray(pkg.directories)) {
- log.warn(pkg.directories, pkg._id + ": invalid 'directories' field")
- delete pkg.directories
- }
- var dirs = pkg.directories = pkg.directories || {}
- , defaults =
- { lib : "./lib"
- , bin : "./bin"
- , man : "./man"
- , doc : "./doc"
- }
- asyncMap(Object.keys(defaults), function (d, cb) {
- if (dirs[d]) return cb()
- fs.stat(path.join(pkgDir, defaults[d]), function (er, s) {
- if (s && s.isDirectory()) dirs[d] = defaults[d]
- cb()
- })
- }, cb)
-}}
-
function readDefaultMans (pkgDir) { return function (pkg, cb) {
var man = pkg.directories && pkg.directories.man
, manDir = path.join(pkgDir, man)
@@ -124,4 +97,3 @@ function readDefaultBins (pkgDir) { return function (pkg, cb) {
cb(null, pkg)
})
}}
-
Please sign in to comment.
Something went wrong with that request. Please try again.