Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2011-06-06 19:42:13 +0400
committerisaacs <i@izs.me>2011-06-06 19:42:13 +0400
commitc0813dd40d518e1fe2704b90cf05fd344c3bb025 (patch)
tree753f801949ef7092cdff140f1d12fc8dd3ccf1be
parent7fa556e4267cfb54f281b7d543bf6a789c9590ec (diff)
Make sure package.json 'files' list is top-priority
-rw-r--r--lib/utils/excludes.js10
-rw-r--r--lib/utils/tar.js21
2 files changed, 14 insertions, 17 deletions
diff --git a/lib/utils/excludes.js b/lib/utils/excludes.js
index 811acec42..1c1bd40ad 100644
--- a/lib/utils/excludes.js
+++ b/lib/utils/excludes.js
@@ -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)
})
}
diff --git a/lib/utils/tar.js b/lib/utils/tar.js
index f004a7d69..09bd29884 100644
--- a/lib/utils/tar.js
+++ b/lib/utils/tar.js
@@ -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)
@@ -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.
@@ -470,11 +458,8 @@ 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"
@@ -482,6 +467,10 @@ function makeList_ (dir, pkg, exList, dfc, cb) {
&& 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))
}