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>2012-03-28 00:51:09 +0400
committerisaacs <i@izs.me>2012-03-28 00:51:09 +0400
commit76f1ec4ccf124242a46572abfed836c96073489c (patch)
treeb260d9890d6c1d75d14f346a61fd29d0bc1ddcc9 /node_modules
parentd3eb770edf8d2cf0376b4f526a4d4a8da5eb387f (diff)
Upgrade fstream-npm
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/fstream-npm/fstream-npm.js130
-rw-r--r--node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js20
-rw-r--r--node_modules/fstream-npm/node_modules/fstream-ignore/package.json8
-rw-r--r--node_modules/fstream-npm/package.json7
4 files changed, 131 insertions, 34 deletions
diff --git a/node_modules/fstream-npm/fstream-npm.js b/node_modules/fstream-npm/fstream-npm.js
index 7771b6b03..bcf78cd13 100644
--- a/node_modules/fstream-npm/fstream-npm.js
+++ b/node_modules/fstream-npm/fstream-npm.js
@@ -1,6 +1,7 @@
var Ignore = require("fstream-ignore")
, inherits = require("inherits")
, path = require("path")
+, fs = require("fs")
module.exports = Packer
@@ -22,6 +23,7 @@ function Packer (props) {
Ignore.call(this, props)
this.bundled = props.bundled
+ this.bundleLinks = props.bundleLinks
this.package = props.package
// in a node_modules folder, resolve symbolic links to
@@ -29,6 +31,13 @@ function Packer (props) {
props.follow = this.follow = this.basename === "node_modules"
// console.error("follow?", this.path, props.follow)
+ if (this === this.root ||
+ this.parent &&
+ this.parent.basename === "node_modules" &&
+ this.basename.charAt(0) !== ".") {
+ this.readBundledLinks()
+ }
+
this.on("entryStat", function (entry, props) {
// files should *always* get into tarballs
@@ -39,28 +48,44 @@ function Packer (props) {
})
}
-Packer.prototype.applyIgnores = function (entry, partial) {
+Packer.prototype.readBundledLinks = function () {
+ if (this._paused) {
+ this.once("resume", this.addIgnoreFiles)
+ return
+ }
+ this.pause()
+ fs.readdir(this.path + "/node_modules", function (er, list) {
+ // no harm if there's no bundle
+ var l = list && list.length
+ if (er || l === 0) return this.resume()
+
+ var errState = null
+ , then = function then (er) {
+ if (errState) return
+ if (er) return errState = er, this.resume()
+ if (-- l === 0) return this.resume()
+ }.bind(this)
+
+ list.forEach(function (pkg) {
+ if (pkg.charAt(0) === ".") return then()
+ var pd = this.path + "/node_modules/" + pkg
+ fs.realpath(pd, function (er, rp) {
+ if (er) return then()
+ this.bundleLinks = this.bundleLinks || {}
+ this.bundleLinks[pkg] = rp
+ then()
+ }.bind(this))
+ }, this)
+ }.bind(this))
+}
+
+Packer.prototype.applyIgnores = function (entry, partial, entryObj) {
// package.json files can never be ignored.
if (entry === "package.json") return true
- // in a node_modules folder, we only include bundled dependencies
- // also, prevent packages in node_modules from being affected
- // by rules set in the containing package, so that
- // bundles don't get busted.
- // Also, once in a bundle, everything is installed as-is
- if (this.bundled) return true
- if (this.basename === "node_modules") {
- if (entry.indexOf("/") === -1) {
- if (this.bundled) return true
- var bd = this.package && this.package.bundleDependencies
- var shouldBundle = bd && bd.indexOf(entry) !== -1
- // console.error("should bundle?", shouldBundle, this.package)
- this.bundled = shouldBundle
- return shouldBundle
- }
- return true
- }
+ // special rules. see below.
+ if (entry === "node_modules") return true
// some files are *never* allowed under any circumstances
if (entry === ".git" ||
@@ -77,7 +102,51 @@ Packer.prototype.applyIgnores = function (entry, partial) {
return false
}
- return Ignore.prototype.applyIgnores.call(this, entry, partial)
+ // in a node_modules folder, we only include bundled dependencies
+ // also, prevent packages in node_modules from being affected
+ // by rules set in the containing package, so that
+ // bundles don't get busted.
+ // Also, once in a bundle, everything is installed as-is
+ // To prevent infinite cycles in the case of cyclic deps that are
+ // linked with npm link, even in a bundle, deps are only bundled
+ // if they're not already present at a higher level.
+ if (this.basename === "node_modules") {
+ // bubbling up. stop here and allow anything the bundled pkg allows
+ if (entry.indexOf("/") !== -1) return true
+
+ // never include the .bin. It's typically full of platform-specific
+ // stuff like symlinks and .cmd files anyway.
+ if (entry === ".bin") return false
+
+ var shouldBundle = false
+ // the package root.
+ var p = this.parent
+ // the package before this one.
+ var pp = p && p.parent
+
+ // if this entry has already been bundled, and is a symlink,
+ // and it is the *same* symlink as this one, then exclude it.
+ if (pp && pp.bundleLinks && this.bundleLinks &&
+ pp.bundleLinks[entry] === this.bundleLinks[entry]) {
+ return false
+ }
+
+ // since it's *not* a symbolic link, if we're *already* in a bundle,
+ // then we should include everything.
+ if (pp && pp.package) {
+ return true
+ }
+
+ // only include it at this point if it's a bundleDependency
+ var bd = this.package && this.package.bundleDependencies
+ var shouldBundle = bd && bd.indexOf(entry) !== -1
+ // if we're not going to bundle it, then it doesn't count as a bundleLink
+ // if (this.bundleLinks && !shouldBundle) delete this.bundleLinks[entry]
+ return shouldBundle
+ }
+ // if (this.bundled) return true
+
+ return Ignore.prototype.applyIgnores.call(this, entry, partial, entryObj)
}
Packer.prototype.addIgnoreFiles = function () {
@@ -96,12 +165,19 @@ Packer.prototype.addIgnoreFiles = function () {
Ignore.prototype.addIgnoreFiles.call(this)
}
+
Packer.prototype.readRules = function (buf, e) {
if (e !== "package.json") {
return Ignore.prototype.readRules.call(this, buf, e)
}
var p = this.package = JSON.parse(buf.toString())
+
+ if (this === this.root) {
+ this.bundleLinks = this.bundleLinks || {}
+ this.bundleLinks[p.name] = this._path
+ }
+
this.packageRoot = true
this.emit("package", p)
@@ -124,7 +200,9 @@ Packer.prototype.getChildProps = function (stat) {
props.package = this.package
- props.bundled = this.bundled
+ props.bundled = this.bundled && this.bundled.slice(0)
+ props.bundleLinks = this.bundleLinks &&
+ Object.create(this.bundleLinks)
// Directories have to be read as Packers
// otherwise fstream.Reader will create a DirReader instead.
@@ -181,9 +259,15 @@ Packer.prototype.emitEntry = function (entry) {
entry.path = path.resolve(entry.dirname, entry.basename)
}
- // skip over symbolic links if we're not in the node_modules
- // folder doing bundle whatevers
- if (this.basename !== "node_modules" && entry.type === "SymbolicLink") {
+ // all *.gyp files are renamed to binding.gyp for node-gyp
+ if (entry.basename.match(/\.gyp$/)) {
+ entry.basename = "binding.gyp"
+ entry.path = path.resolve(entry.dirname, entry.basename)
+ }
+
+ // skip over symbolic links
+ if (entry.type === "SymbolicLink") {
+ entry.abort()
return
}
diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js b/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js
index 839ad56ae..0728f7c8f 100644
--- a/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js
+++ b/node_modules/fstream-npm/node_modules/fstream-ignore/ignore.js
@@ -56,9 +56,11 @@ function IgnoreReader (props) {
// however, directories have to be re-tested against
// rules with a "/" appended, because "a/b/" will only
// match if "a/b" is a dir, and not otherwise.
- this.on("entryStat", function (entry, props) {
+ this.on("_entryStat", function (entry, props) {
var t = entry.basename
- if (!this.applyIgnores(entry.basename, entry.type === "Directory")) {
+ if (!this.applyIgnores(entry.basename,
+ entry.type === "Directory",
+ entry)) {
entry.abort()
}
}.bind(this))
@@ -68,11 +70,21 @@ function IgnoreReader (props) {
IgnoreReader.prototype.addIgnoreFiles = function () {
- this.pause()
+ if (this._paused) {
+ this.once("resume", this.addIgnoreFiles)
+ return
+ }
+ if (this._ignoreFilesAdded) return
+ this._ignoreFilesAdded = true
+
var newIg = this.entries.filter(this.isIgnoreFile, this)
, count = newIg.length
, errState = null
+ if (!count) return
+
+ this.pause()
+
var then = function then (er) {
if (errState) return
if (er) return this.emit("error", errState = er)
@@ -171,7 +183,7 @@ IgnoreReader.prototype.filterEntries = function () {
}
-IgnoreReader.prototype.applyIgnores = function (entry, partial) {
+IgnoreReader.prototype.applyIgnores = function (entry, partial, obj) {
var included = true
// this = /a/b/c
diff --git a/node_modules/fstream-npm/node_modules/fstream-ignore/package.json b/node_modules/fstream-npm/node_modules/fstream-ignore/package.json
index 867091ea0..0731db462 100644
--- a/node_modules/fstream-npm/node_modules/fstream-ignore/package.json
+++ b/node_modules/fstream-npm/node_modules/fstream-ignore/package.json
@@ -6,7 +6,7 @@
},
"name": "fstream-ignore",
"description": "A thing for ignoring files based on globs",
- "version": "0.0.3",
+ "version": "0.0.5",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/fstream-ignore.git"
@@ -17,7 +17,7 @@
},
"dependencies": {
"minimatch": "~0.2.0",
- "fstream": "~0.1.15",
+ "fstream": "~0.1.17",
"inherits": "~1.0.0"
},
"devDependencies": {
@@ -29,7 +29,7 @@
"name": "isaacs",
"email": "i@izs.me"
},
- "_id": "fstream-ignore@0.0.3",
+ "_id": "fstream-ignore@0.0.5",
"optionalDependencies": {},
"engines": {
"node": "*"
@@ -38,5 +38,5 @@
"_npmVersion": "1.1.12",
"_nodeVersion": "v0.7.7-pre",
"_defaultsLoaded": true,
- "_from": "fstream-ignore@~0.0.2"
+ "_from": "fstream-ignore@~0.0.5"
}
diff --git a/node_modules/fstream-npm/package.json b/node_modules/fstream-npm/package.json
index 57a950e7b..84b9f3480 100644
--- a/node_modules/fstream-npm/package.json
+++ b/node_modules/fstream-npm/package.json
@@ -6,20 +6,21 @@
},
"name": "fstream-npm",
"description": "fstream class for creating npm packages",
- "version": "0.0.2",
+ "version": "0.0.3",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/fstream-npm.git"
},
"main": "./fstream-npm.js",
"dependencies": {
- "fstream-ignore": "~0.0.2"
+ "fstream-ignore": "~0.0.5",
+ "inherits": ""
},
"_npmUser": {
"name": "isaacs",
"email": "i@izs.me"
},
- "_id": "fstream-npm@0.0.2",
+ "_id": "fstream-npm@0.0.3",
"devDependencies": {},
"optionalDependencies": {},
"engines": {