Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Make sure package.json 'files' list is top-priority
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jun 6, 2011
1 parent 7fa556e commit c0813dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
10 changes: 9 additions & 1 deletion lib/utils/excludes.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ function addIgnoreFile (file, gitBase, list, dir, cb) {
if (typeof cb !== "function") cb = dir, dir = path.dirname(file)
if (typeof cb !== "function") cb = list, list = []
parseIgnoreFile(file, gitBase, dir, function (er, data) {
if (!er && data) list = list.concat([data])
if (!er && data) {
// package.json "files" array trumps everything
// Make sure it's always last.
if (list.length && list[list.length-1].packageFiles) {
list = list.concat([data, list.pop()])
} else {
list = list.concat([data])
}
}
cb(er, list)
})
}
Expand Down
21 changes: 5 additions & 16 deletions lib/utils/tar.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,6 @@ function makeList (dir, pkg, dfc, cb) {
function next () {
if (!globalExclude || !userExclude) return
var exList = [ defIgnore, confIgnore, globalExclude, userExclude ]
if (pkg.files) {
var fileInc = pkg.files.map(function (f) {
return "!" + f
})
fileInc.push("!package.json")
fileInc.dir = pkg.path
exList.push(fileInc)
}

makeList_(dir, pkg, exList, dfc, function (er, files, cleanup) {
if (er) return cb(er)
Expand Down Expand Up @@ -458,10 +450,6 @@ function makeList_ (dir, pkg, exList, dfc, cb) {
if (er) return cb(errState = er, [], cleanup)
if (-- n > 0) return

//files = files.map(function (f) {
// return path.resolve(dir, f)
//})

if (!pkg) return cb(new Error("No package.json file in "+dir))
if (pkg.path === dir && pkg.files) {
// stuff on the files list MUST be there.
Expand All @@ -470,18 +458,19 @@ function makeList_ (dir, pkg, exList, dfc, cb) {
return "!" + f
}))
pkgFiles.dir = dir
pkgFiles.packageFiles = true
exList.push(pkgFiles)
// if there's a files list, then we want to *only* include
// files on that list. So, do an exclusion filter *now*,
// before even going any further.
files = files.filter(excludes.filter(dir, [pkgFiles]))
}

if (path.basename(dir) === "node_modules"
&& pkg.path === path.dirname(dir)
&& dfc) { // do fancy crap
files = filterNodeModules(files, pkg)
} else {
// FIXME If a directory is excluded, we still need to be
// able to *include* a file within it, and have that override
// the prior exclusion.
// This whole makeList thing probably needs to be rewritten
files = files.filter(excludes.filter(dir, exList))
}

Expand Down

0 comments on commit c0813dd

Please sign in to comment.