Skip to content
Browse files

Abstract out graceful-fs

  • Loading branch information...
1 parent e7c7051 commit 98b6a1070aced5850e2a2827273000b6ad96b3bc @isaacs isaacs committed Jul 20, 2011
View
3 .gitmodules
@@ -13,3 +13,6 @@
[submodule "node_modules/minimatch"]
path = node_modules/minimatch
url = git://github.com/isaacs/minimatch.git
+[submodule "node_modules/graceful-fs"]
+ path = node_modules/graceful-fs
+ url = git://github.com/isaacs/node-graceful-fs.git
View
2 bin/npm.js
@@ -4,7 +4,7 @@ var log = require("../lib/utils/log")
log.waitForConfig()
log.info("ok", "it worked if it ends with")
-var fs = require("../lib/utils/graceful-fs")
+var fs = require("graceful-fs")
, path = require("path")
, sys = require("../lib/utils/sys")
, npm = require("../npm")
View
2 lib/build.js
@@ -11,7 +11,7 @@
var npm = require("../npm")
, log = require("./utils/log")
, chain = require("./utils/chain")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, path = require("path")
, lifecycle = require("./utils/lifecycle")
, readJson = require("./utils/read-json")
View
2 lib/cache.js
@@ -35,7 +35,7 @@ var mkdir = require("./utils/mkdir-p")
, exec = require("./utils/exec")
, fetch = require("./utils/fetch")
, npm = require("../npm")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, rm = require("./utils/rm-rf")
, readJson = require("./utils/read-json")
, registry = require("./utils/npm-registry-client")
View
2 lib/completion.js
@@ -139,7 +139,7 @@ function completion (args, cb) {
}
function dumpScript (cb) {
- var fs = require("./utils/graceful-fs")
+ var fs = require("graceful-fs")
, path = require("path")
, p = path.resolve(__dirname, "utils/completion.sh")
View
2 lib/config.js
@@ -11,7 +11,7 @@ var ini = require("./utils/ini")
, log = require("./utils/log")
, npm = require("../npm")
, exec = require("./utils/exec")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, dc
, output = require("./utils/output")
, types = require("./utils/config-defs").types
View
2 lib/edit.js
@@ -9,7 +9,7 @@ edit.completion = require("./utils/completion/installed-shallow")
var npm = require("../npm")
, exec = require("./utils/exec")
, path = require("path")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, log = require("./utils/log")
function edit (args, cb) {
View
2 lib/explore.js
@@ -8,7 +8,7 @@ explore.completion = require("./utils/completion/installed-shallow")
var npm = require("../npm")
, exec = require("./utils/exec")
, path = require("path")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
function explore (args, cb) {
if (args.length < 1 || !args[0]) return cb(explore.usage)
View
2 lib/help-search.js
@@ -1,7 +1,7 @@
module.exports = helpSearch
-var fs = require("./utils/graceful-fs")
+var fs = require("graceful-fs")
, output = require("./utils/output")
, path = require("path")
, asyncMap = require("./utils/async-map")
View
2 lib/help.js
@@ -6,7 +6,7 @@ help.completion = function (opts, cb) {
getSections(cb)
}
-var fs = require("./utils/graceful-fs")
+var fs = require("graceful-fs")
, path = require("path")
, exec = require("./utils/exec")
, npm = require("../npm")
View
2 lib/init.js
@@ -6,7 +6,7 @@ module.exports = init
var prompt = require("./utils/prompt")
, path = require("path")
, readJson = require("./utils/read-json")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, promiseChain = require("./utils/promise-chain")
, exec = require("./utils/exec")
, semver = require("semver")
View
2 lib/install.js
@@ -136,7 +136,7 @@ var npm = require("../npm")
, readJson = require("./utils/read-json")
, log = require("./utils/log")
, path = require("path")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, cache = require("./cache")
, asyncMap = require("./utils/async-map")
, chain = require("./utils/chain")
View
2 lib/link.js
@@ -4,7 +4,7 @@
var npm = require("../npm")
, symlink = require("./utils/link")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, log = require("./utils/log")
, asyncMap = require("./utils/async-map")
, chain = require("./utils/chain")
View
2 lib/outdated.js
@@ -19,7 +19,7 @@ outdated.completion = require("./utils/completion/installed-deep")
var path = require("path")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, readJson = require("./utils/read-json")
, cache = require("./cache")
, asyncMap = require("./utils/async-map")
View
2 lib/pack.js
@@ -8,7 +8,7 @@ var npm = require("../npm")
, install = require("./install")
, cache = require("./cache")
, output = require("./utils/output")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, chain = require("./utils/chain")
, path = require("path")
, relativize = require("./utils/relativize")
View
2 lib/run-script.js
@@ -7,7 +7,7 @@ var lifecycle = require("./utils/lifecycle")
, readJson = require("./utils/read-json")
, log = require("./utils/log")
, chain = require("./utils/chain")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, asyncMap = require("./utils/async-map")
runScript.usage = "npm run-script [<pkg>] <command>"
View
2 lib/unbuild.js
@@ -5,7 +5,7 @@ var readJson = require("./utils/read-json")
, rm = require("./utils/rm-rf")
, npm = require("../npm")
, path = require("path")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, lifecycle = require("./utils/lifecycle")
, asyncMap = require("./utils/async-map")
, chain = require("./utils/chain")
View
2 lib/uninstall.js
@@ -11,7 +11,7 @@ uninstall.usage = "npm uninstall <name>[@<version> [<name>[@<version>] ...]"
uninstall.completion = require("./utils/completion/installed-shallow")
var rm = require("./utils/rm-rf")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, log = require("./utils/log")
, readJson = require("./utils/read-json")
, path = require("path")
View
2 lib/utils/completion/installed-shallow.js
@@ -2,7 +2,7 @@
module.exports = installedShallow
var npm = require("../../../npm")
- , fs = require("../graceful-fs")
+ , fs = require("graceful-fs")
, path = require("path")
, readJson = require("../read-json")
, asyncMap = require("../async-map")
View
2 lib/utils/error-handler.js
@@ -176,7 +176,7 @@ function exit (code) {
}
function writeLogFile (cb) {
- var fs = require("./graceful-fs")
+ var fs = require("graceful-fs")
, fstr = fs.createWriteStream("npm-debug.log")
, sys = require("util")
View
2 lib/utils/excludes.js
@@ -24,7 +24,7 @@ exports.test = test
exports.filter = filter
var path = require("path")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
, minimatch = require("minimatch")
, relativize = require("./relativize")
, log = require("./log")
View
2 lib/utils/fetch.js
@@ -6,7 +6,7 @@ var http
, https
, url = require("url")
, sys = require("./sys")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
, get = require("./get")
, set = require("./set")
, log = require("./log")
View
2 lib/utils/find-prefix.js
@@ -2,7 +2,7 @@
module.exports = findPrefix
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, path = require("path")
, npm = require("../../npm")
View
2 lib/utils/find.js
@@ -4,7 +4,7 @@
// provided.
module.exports = find
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, asyncMap = require("./async-map")
, path = require("path")
View
34 lib/utils/graceful-fs.js
@@ -1,34 +0,0 @@
-
-// wrapper around the non-sync fs functions to gracefully handle
-// having too many file descriptors open. Note that this is
-// *only* possible because async patterns let one interject timeouts
-// and other cleverness anywhere in the process without disrupting
-// anything else.
-var fs = require("fs")
- , timeout = 0
-
-Object.keys(fs)
- .forEach(function (i) {
- exports[i] = (typeof fs[i] !== "function") ? fs[i]
- : (i.match(/^[A-Z]|^create|Sync$/)) ? function () {
- return fs[i].apply(fs, arguments)
- }
- : graceful(fs[i])
- })
-
-function graceful (fn) { return function GRACEFUL () {
- var args = Array.prototype.slice.call(arguments)
- , cb_ = args.pop()
- args.push(cb)
- function cb (er) {
- if (er && er.message.match(/^EMFILE, Too many open files/)) {
- setTimeout(function () {
- GRACEFUL.apply(fs, args)
- }, timeout ++)
- return
- }
- timer = 0
- cb_.apply(null, arguments)
- }
- fn.apply(fs, args)
-}}
View
2 lib/utils/ini.js
@@ -28,7 +28,7 @@ exports.defaultConfig = null
Object.defineProperty(exports, "keys",
{ get : function () { return configList.keys }})
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, path = require("path")
, sys = require("./sys")
View
2 lib/utils/lifecycle.js
@@ -7,7 +7,7 @@ var log = require("./log")
, npm = require("../../npm")
, path = require("path")
, readJson = require("./read-json")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
, chain = require("./chain")
, asyncMap = require("./async-map")
, constants = require("constants")
View
2 lib/utils/link.js
@@ -2,7 +2,7 @@
module.exports = link
link.ifExists = linkIfExists
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, chain = require("./chain")
, mkdir = require("./mkdir-p")
, rm = require("./rm-rf")
View
2 lib/utils/load-package-defaults.js
@@ -6,7 +6,7 @@ var path = require("path")
, find = require("./find")
, asyncMap = require("./async-map")
, npm = require("../../npm")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
function loadPackageDefaults (pkg, pkgDir, cb) {
if (!pkg) return cb(new Error("no package to load defaults from!"))
View
2 lib/utils/mkdir-p.js
@@ -1,6 +1,6 @@
var log = require("./log")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
, path = require("path")
, npm = require("../../npm")
, exec = require("./exec")
View
2 lib/utils/npm-registry-client/get.js
@@ -2,7 +2,7 @@
module.exports = get
var GET = require("./request").GET
- , fs = require("../graceful-fs")
+ , fs = require("graceful-fs")
, npm = require("../../../npm")
, path = require("path")
, log = require("../log")
View
2 lib/utils/npm-registry-client/request.js
@@ -11,7 +11,7 @@ var npm = require("../../../npm")
, url = require("url")
, log = require("../log")
, ini = require("../ini")
- , fs = require("../graceful-fs")
+ , fs = require("graceful-fs")
, rm = require("../rm-rf")
, asyncMap = require("../async-map")
, proxyify = require("../proxyify")
View
2 lib/utils/read-installed.js
@@ -88,7 +88,7 @@ as far as the left-most node_modules folder.
var npm = require("../../npm")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
, path = require("path")
, asyncMap = require("./async-map")
, semver = require("semver")
View
2 lib/utils/read-json.js
@@ -4,7 +4,7 @@ readJson.processJson = processJson
readJson.unParsePeople = unParsePeople
readJson.parsePeople = parsePeople
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, semver = require("semver")
, path = require("path")
, log = require("./log")
View
2 lib/utils/rm-rf.js
@@ -3,7 +3,7 @@
module.exports = rm
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, path = require("path")
, failedToRemove = []
, log = require("./log")
View
2 lib/utils/sha.js
@@ -1,5 +1,5 @@
-var fs = require("./graceful-fs")
+var fs = require("graceful-fs")
, crypto = require("crypto")
, log = require("./log")
, binding
View
2 lib/utils/tar.js
@@ -4,7 +4,7 @@
var FMODE = exports.FMODE = 0644
, DMODE = exports.DMODE = 0755
, npm = require("../../npm")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
, exec = require("./exec")
, spawn = exec.spawn
, pipe = exec.pipe
View
2 lib/utils/which.js
@@ -2,7 +2,7 @@ module.exports = which
which.sync = whichSync
var path = require("path")
- , fs = require("./graceful-fs")
+ , fs = require("graceful-fs")
// console.log(process.execPath)
// console.log(process.argv)
View
2 lib/version.js
@@ -6,7 +6,7 @@ var exec = require("./utils/exec")
, readJson = require("./utils/read-json")
, semver = require("semver")
, path = require("path")
- , fs = require("./utils/graceful-fs")
+ , fs = require("graceful-fs")
, chain = require("./utils/chain")
, log = require("./utils/log")
, npm = require("../npm")
1 node_modules/graceful-fs
@@ -0,0 +1 @@
+Subproject commit 9d7cd989c77b39ccd58ce147e2fe86ca5aeafe0e
View
2 npm.js
@@ -16,7 +16,7 @@ var EventEmitter = require("events").EventEmitter
, get = require("./lib/utils/get")
, ini = require("./lib/utils/ini")
, log = require("./lib/utils/log")
- , fs = require("./lib/utils/graceful-fs")
+ , fs = require("graceful-fs")
, path = require("path")
, abbrev = require("abbrev")
, which = require("./lib/utils/which")
View
3 package.json
@@ -26,11 +26,12 @@
, "dependencies" :
{ "semver" : "1"
, "abbrev" : "1"
+ , "graceful-fs" : "1"
, "minimatch" : "0"
, "nopt" : "1"
, "node-uuid" : "1.2" }
, "bundleDependencies" :
- [ "semver", "abbrev", "minimatch", "nopt", "node-uuid" ]
+ [ "semver", "abbrev", "graceful-fs", "minimatch", "nopt", "node-uuid" ]
, "devDependencies" : { "ronn" : "" }
, "engines" : { "node" : "0.4 || 0.5", "npm" : "1" }
, "scripts" : { "test" : "./test/run.sh"

0 comments on commit 98b6a10

Please sign in to comment.
Something went wrong with that request. Please try again.