fsevents 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fsevents might be problematic. Click here for more details.

Files changed (149) hide show
  1. package/node_modules/node-pre-gyp/CHANGELOG.md +9 -0
  2. package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +32 -0
  3. package/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist/package.json +2 -1
  4. package/node_modules/node-pre-gyp/node_modules/nopt/README.md +8 -7
  5. package/node_modules/node-pre-gyp/node_modules/nopt/package.json +16 -12
  6. package/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json +1 -1
  7. package/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
  8. package/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/package.json +1 -1
  9. package/node_modules/node-pre-gyp/node_modules/rc/lib/utils.js +2 -2
  10. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/index.js +14 -2
  11. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/package.json +10 -9
  12. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/bool.js +23 -0
  13. package/node_modules/node-pre-gyp/node_modules/rc/node_modules/minimist/test/kv_short.js +16 -0
  14. package/node_modules/node-pre-gyp/node_modules/rc/package.json +9 -8
  15. package/node_modules/node-pre-gyp/node_modules/request/.travis.yml +1 -0
  16. package/node_modules/node-pre-gyp/node_modules/request/CHANGELOG.md +22 -2
  17. package/node_modules/node-pre-gyp/node_modules/request/README.md +42 -10
  18. package/node_modules/node-pre-gyp/node_modules/request/index.js +4 -0
  19. package/node_modules/node-pre-gyp/node_modules/request/node_modules/aws-sign2/package.json +1 -1
  20. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/core-util-is/package.json +1 -1
  21. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/inherits/package.json +1 -1
  22. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args/index.js +1 -1
  23. package/node_modules/node-pre-gyp/node_modules/request/node_modules/{form-data/node_modules/async/LICENSE → bl/node_modules/readable-stream/node_modules/process-nextick-args/license.md} +6 -6
  24. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args/package.json +10 -9
  25. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/node_modules/process-nextick-args/test.js +7 -0
  26. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/node_modules/readable-stream/package.json +2 -1
  27. package/node_modules/node-pre-gyp/node_modules/request/node_modules/bl/package.json +2 -1
  28. package/node_modules/node-pre-gyp/node_modules/request/node_modules/caseless/package.json +2 -1
  29. package/node_modules/node-pre-gyp/node_modules/request/node_modules/extend/package.json +2 -1
  30. package/node_modules/node-pre-gyp/node_modules/request/node_modules/forever-agent/package.json +1 -1
  31. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/Readme.md +44 -9
  32. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/lib/form_data.js +48 -25
  33. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/lib/async.js +13 -7
  34. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/package.json +26 -11
  35. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/package.json +29 -20
  36. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/README.md +4 -1
  37. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.js +35 -11
  38. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/browser/bluebird.min.js +5 -5
  39. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/debuggability.js +2 -0
  40. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/direct_resolve.js +2 -0
  41. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/promise.js +5 -1
  42. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/promisify.js +10 -5
  43. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/js/main/using.js +14 -3
  44. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/bluebird/package.json +9 -8
  45. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/index.js +2 -2
  46. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/escape-string-regexp/package.json +1 -1
  47. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/package.json +22 -15
  48. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/chalk/readme.md +3 -2
  49. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/commander/package.json +1 -1
  50. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/README.md +1 -1
  51. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-function/package.json +1 -1
  52. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/generate-object-property/package.json +1 -1
  53. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/.travis.yml +6 -2
  54. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/README.md +3 -2
  55. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/jsonpointer.js +7 -10
  56. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/package.json +24 -20
  57. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/node_modules/jsonpointer/test.js +11 -13
  58. package/node_modules/node-pre-gyp/node_modules/request/node_modules/har-validator/node_modules/is-my-json-valid/package.json +11 -10
  59. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/.travis.yml +3 -2
  60. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/lib/index.js +39 -28
  61. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/package.json +11 -12
  62. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/boom/test/index.js +1 -1
  63. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/.npmignore +18 -18
  64. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/.travis.yml +8 -5
  65. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +2 -0
  66. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +24 -28
  67. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/test/index.js +57 -63
  68. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/.travis.yml +2 -2
  69. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/LICENSE +0 -0
  70. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/README.md +16 -6
  71. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/images/hoek.png +0 -0
  72. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/lib/escape.js +0 -0
  73. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/lib/index.js +24 -8
  74. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/package.json +13 -13
  75. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/escaper.js +0 -0
  76. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/index.js +866 -778
  77. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test1.js +0 -0
  78. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test2.js +0 -0
  79. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/test/modules/test3.js +0 -0
  80. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/sntp/package.json +1 -1
  81. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/package.json +2 -1
  82. package/node_modules/node-pre-gyp/node_modules/request/node_modules/http-signature/node_modules/assert-plus/package.json +1 -1
  83. package/node_modules/node-pre-gyp/node_modules/request/node_modules/http-signature/node_modules/ctype/package.json +1 -1
  84. package/node_modules/node-pre-gyp/node_modules/request/node_modules/isstream/package.json +1 -1
  85. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/HISTORY.md +24 -0
  86. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/index.js +1 -1
  87. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/node_modules/mime-db/HISTORY.md +33 -0
  88. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/node_modules/mime-db/db.json +50 -0
  89. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/node_modules/mime-db/package.json +12 -13
  90. package/node_modules/node-pre-gyp/node_modules/request/node_modules/mime-types/package.json +9 -10
  91. package/node_modules/node-pre-gyp/node_modules/request/node_modules/node-uuid/package.json +1 -1
  92. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.npmignore +0 -1
  93. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/.travis.yml +3 -2
  94. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/CHANGELOG.md +13 -2
  95. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/README.md +11 -4
  96. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/bower.json +1 -1
  97. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/component.json +15 -0
  98. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/dist/qs.js +523 -0
  99. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/parse.js +3 -2
  100. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/lib/stringify.js +28 -7
  101. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/package.json +20 -18
  102. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/parse.js +14 -14
  103. package/node_modules/node-pre-gyp/node_modules/request/node_modules/qs/test/stringify.js +23 -1
  104. package/node_modules/node-pre-gyp/node_modules/request/node_modules/stringstream/package.json +1 -1
  105. package/node_modules/node-pre-gyp/node_modules/request/package.json +12 -12
  106. package/node_modules/node-pre-gyp/node_modules/request/request.js +51 -30
  107. package/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/inherits/package.json +1 -1
  108. package/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/node_modules/minimatch/package.json +3 -2
  109. package/node_modules/node-pre-gyp/node_modules/rimraf/node_modules/glob/package.json +2 -1
  110. package/node_modules/node-pre-gyp/node_modules/rimraf/package.json +9 -8
  111. package/node_modules/node-pre-gyp/node_modules/rimraf/rimraf.js +1 -1
  112. package/node_modules/node-pre-gyp/node_modules/semver/package.json +10 -12
  113. package/node_modules/node-pre-gyp/node_modules/semver/semver.js +1 -0
  114. package/node_modules/node-pre-gyp/node_modules/semver/test/index.js +21 -8
  115. package/node_modules/node-pre-gyp/node_modules/tar/lib/entry.js +7 -0
  116. package/node_modules/node-pre-gyp/node_modules/tar/lib/parse.js +5 -1
  117. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/fs.js +21 -11
  118. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/graceful-fs.js +208 -115
  119. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/legacy-streams.js +118 -0
  120. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/package.json +18 -17
  121. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/polyfills.js +130 -133
  122. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/package.json +18 -14
  123. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/inherits/package.json +1 -1
  124. package/node_modules/node-pre-gyp/node_modules/tar/package.json +22 -15
  125. package/node_modules/node-pre-gyp/node_modules/tar/test/parse-discard.js +29 -0
  126. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/inherits/package.json +1 -1
  127. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/README.md +12 -2
  128. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +48 -4
  129. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/package.json +9 -9
  130. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/test/basic.js +26 -25
  131. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/fstream-ignore/node_modules/minimatch/node_modules/lru-cache/test/serialize.js +216 -0
  132. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/readable-stream/node_modules/core-util-is/package.json +1 -1
  133. package/node_modules/node-pre-gyp/node_modules/tar-pack/node_modules/readable-stream/package.json +1 -1
  134. package/node_modules/node-pre-gyp/package.json +10 -10
  135. package/package.json +2 -2
  136. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/.jscsrc +0 -3
  137. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/CHANGELOG.md +0 -81
  138. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/README.md +0 -1789
  139. package/node_modules/node-pre-gyp/node_modules/request/node_modules/form-data/node_modules/async/support/sync-package-managers.js +0 -53
  140. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/Makefile +0 -9
  141. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/cryptiles/index.js +0 -1
  142. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/Makefile +0 -8
  143. package/node_modules/node-pre-gyp/node_modules/request/node_modules/hawk/node_modules/hoek/index.js +0 -1
  144. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/.npmignore +0 -1
  145. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/LICENSE +0 -15
  146. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/max-open.js +0 -69
  147. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/open.js +0 -39
  148. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/readdir-sort.js +0 -20
  149. package/node_modules/node-pre-gyp/node_modules/tar/node_modules/fstream/node_modules/graceful-fs/test/write-then-read.js +0 -47
@@ -1,11 +1,7 @@
1
- // Monkey-patching the fs module.
2
- // It's ugly, but there is simply no other way to do this.
3
- var fs = module.exports = require('./fs.js')
4
-
5
- var assert = require('assert')
6
-
7
- // fix up some busted stuff, mostly on windows and old nodes
8
- require('./polyfills.js')
1
+ var fs = require('fs')
2
+ var polyfills = require('./polyfills.js')
3
+ var legacy = require('./legacy-streams.js')
4
+ var queue = []
9
5
 
10
6
  var util = require('util')
11
7
 
@@ -13,146 +9,243 @@ function noop () {}
13
9
 
14
10
  var debug = noop
15
11
  if (util.debuglog)
16
- debug = util.debuglog('gfs')
17
- else if (/\bgfs\b/i.test(process.env.NODE_DEBUG || ''))
12
+ debug = util.debuglog('gfs4')
13
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
18
14
  debug = function() {
19
15
  var m = util.format.apply(util, arguments)
20
- m = 'GFS: ' + m.split(/\n/).join('\nGFS: ')
16
+ m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
21
17
  console.error(m)
22
18
  }
23
19
 
24
- if (/\bgfs\b/i.test(process.env.NODE_DEBUG || '')) {
20
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
25
21
  process.on('exit', function() {
26
- debug('fds', fds)
27
22
  debug(queue)
28
- assert.equal(queue.length, 0)
23
+ require('assert').equal(queue.length, 0)
29
24
  })
30
25
  }
31
26
 
32
-
33
- var originalOpen = fs.open
34
- fs.open = open
35
-
36
- function open(path, flags, mode, cb) {
37
- if (typeof mode === "function") cb = mode, mode = null
38
- if (typeof cb !== "function") cb = noop
39
- new OpenReq(path, flags, mode, cb)
27
+ module.exports = patch(require('./fs.js'))
28
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH) {
29
+ module.exports = patch(fs)
40
30
  }
41
31
 
42
- function OpenReq(path, flags, mode, cb) {
43
- this.path = path
44
- this.flags = flags
45
- this.mode = mode
46
- this.cb = cb
47
- Req.call(this)
48
- }
49
-
50
- util.inherits(OpenReq, Req)
51
-
52
- OpenReq.prototype.process = function() {
53
- originalOpen.call(fs, this.path, this.flags, this.mode, this.done)
54
- }
55
-
56
- var fds = {}
57
- OpenReq.prototype.done = function(er, fd) {
58
- debug('open done', er, fd)
59
- if (fd)
60
- fds['fd' + fd] = this.path
61
- Req.prototype.done.call(this, er, fd)
62
- }
63
-
64
-
65
- var originalReaddir = fs.readdir
66
- fs.readdir = readdir
32
+ // Always patch fs.close/closeSync, because we want to
33
+ // retry() whenever a close happens *anywhere* in the program.
34
+ // This is essential when multiple graceful-fs instances are
35
+ // in play at the same time.
36
+ fs.close = (function (fs$close) { return function (fd, cb) {
37
+ return fs$close.call(fs, fd, function (err) {
38
+ if (!err)
39
+ retry()
40
+
41
+ if (typeof cb === 'function')
42
+ cb.apply(this, arguments)
43
+ })
44
+ }})(fs.close)
45
+
46
+ fs.closeSync = (function (fs$closeSync) { return function (fd) {
47
+ // Note that graceful-fs also retries when fs.closeSync() fails.
48
+ // Looks like a bug to me, although it's probably a harmless one.
49
+ var rval = fs$closeSync.apply(fs, arguments)
50
+ retry()
51
+ return rval
52
+ }})(fs.closeSync)
53
+
54
+ function patch (fs) {
55
+ // Everything that references the open() function needs to be in here
56
+ polyfills(fs)
57
+ fs.gracefulify = patch
58
+ fs.FileReadStream = ReadStream; // Legacy name.
59
+ fs.FileWriteStream = WriteStream; // Legacy name.
60
+ fs.createReadStream = createReadStream
61
+ fs.createWriteStream = createWriteStream
62
+ var fs$readFile = fs.readFile
63
+ fs.readFile = readFile
64
+ function readFile (path, options, cb) {
65
+ if (typeof options === 'function')
66
+ cb = options, options = null
67
+
68
+ return go$readFile(path, options, cb)
69
+
70
+ function go$readFile (path, options, cb) {
71
+ return fs$readFile(path, options, function (err) {
72
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
73
+ enqueue([go$readFile, [path, options, cb]])
74
+ else {
75
+ if (typeof cb === 'function')
76
+ cb.apply(this, arguments)
77
+ retry()
78
+ }
79
+ })
80
+ }
81
+ }
67
82
 
68
- function readdir(path, cb) {
69
- if (typeof cb !== "function") cb = noop
70
- new ReaddirReq(path, cb)
71
- }
83
+ var fs$writeFile = fs.writeFile
84
+ fs.writeFile = writeFile
85
+ function writeFile (path, data, options, cb) {
86
+ if (typeof options === 'function')
87
+ cb = options, options = null
88
+
89
+ return go$writeFile(path, data, options, cb)
90
+
91
+ function go$writeFile (path, data, options, cb) {
92
+ return fs$writeFile(path, data, options, function (err) {
93
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
94
+ enqueue([go$writeFile, [path, data, options, cb]])
95
+ else {
96
+ if (typeof cb === 'function')
97
+ cb.apply(this, arguments)
98
+ retry()
99
+ }
100
+ })
101
+ }
102
+ }
72
103
 
73
- function ReaddirReq(path, cb) {
74
- this.path = path
75
- this.cb = cb
76
- Req.call(this)
77
- }
104
+ var fs$appendFile = fs.appendFile
105
+ if (fs$appendFile)
106
+ fs.appendFile = appendFile
107
+ function appendFile (path, data, options, cb) {
108
+ if (typeof options === 'function')
109
+ cb = options, options = null
110
+
111
+ return go$appendFile(path, data, options, cb)
112
+
113
+ function go$appendFile (path, data, options, cb) {
114
+ return fs$appendFile(path, data, options, function (err) {
115
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
116
+ enqueue([go$appendFile, [path, data, options, cb]])
117
+ else {
118
+ if (typeof cb === 'function')
119
+ cb.apply(this, arguments)
120
+ retry()
121
+ }
122
+ })
123
+ }
124
+ }
78
125
 
79
- util.inherits(ReaddirReq, Req)
126
+ var fs$readdir = fs.readdir
127
+ fs.readdir = readdir
128
+ function readdir (path, cb) {
129
+ return go$readdir(path, cb)
130
+
131
+ function go$readdir () {
132
+ return fs$readdir(path, function (err, files) {
133
+ if (files && files.sort)
134
+ files.sort(); // Backwards compatibility with graceful-fs.
135
+
136
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
137
+ enqueue([go$readdir, [path, cb]])
138
+ else {
139
+ if (typeof cb === 'function')
140
+ cb.apply(this, arguments)
141
+ retry()
142
+ }
143
+ })
144
+ }
145
+ }
80
146
 
81
- ReaddirReq.prototype.process = function() {
82
- originalReaddir.call(fs, this.path, this.done)
83
- }
84
147
 
85
- ReaddirReq.prototype.done = function(er, files) {
86
- if (files && files.sort)
87
- files = files.sort()
88
- Req.prototype.done.call(this, er, files)
89
- onclose()
90
- }
148
+ if (process.version.substr(0, 4) === 'v0.8') {
149
+ var legStreams = legacy(fs)
150
+ ReadStream = legStreams.ReadStream
151
+ WriteStream = legStreams.WriteStream
152
+ }
91
153
 
154
+ var fs$ReadStream = fs.ReadStream
155
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype)
156
+ ReadStream.prototype.open = ReadStream$open
92
157
 
93
- var originalClose = fs.close
94
- fs.close = close
158
+ var fs$WriteStream = fs.WriteStream
159
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype)
160
+ WriteStream.prototype.open = WriteStream$open
95
161
 
96
- function close (fd, cb) {
97
- debug('close', fd)
98
- if (typeof cb !== "function") cb = noop
99
- delete fds['fd' + fd]
100
- originalClose.call(fs, fd, function(er) {
101
- onclose()
102
- cb(er)
103
- })
104
- }
162
+ fs.ReadStream = ReadStream
163
+ fs.WriteStream = WriteStream
105
164
 
165
+ function ReadStream (path, options) {
166
+ if (this instanceof ReadStream)
167
+ return fs$ReadStream.apply(this, arguments), this
168
+ else
169
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
170
+ }
106
171
 
107
- var originalCloseSync = fs.closeSync
108
- fs.closeSync = closeSync
172
+ function ReadStream$open () {
173
+ var that = this
174
+ open(that.path, that.flags, that.mode, function (err, fd) {
175
+ if (err) {
176
+ if (that.autoClose)
177
+ that.destroy()
178
+
179
+ that.emit('error', err)
180
+ } else {
181
+ that.fd = fd
182
+ that.emit('open', fd)
183
+ that.read()
184
+ }
185
+ })
186
+ }
109
187
 
110
- function closeSync (fd) {
111
- try {
112
- return originalCloseSync(fd)
113
- } finally {
114
- onclose()
188
+ function WriteStream (path, options) {
189
+ if (this instanceof WriteStream)
190
+ return fs$WriteStream.apply(this, arguments), this
191
+ else
192
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
115
193
  }
116
- }
117
194
 
195
+ function WriteStream$open () {
196
+ var that = this
197
+ open(that.path, that.flags, that.mode, function (err, fd) {
198
+ if (err) {
199
+ that.destroy()
200
+ that.emit('error', err)
201
+ } else {
202
+ that.fd = fd
203
+ that.emit('open', fd)
204
+ }
205
+ })
206
+ }
118
207
 
119
- // Req class
120
- function Req () {
121
- // start processing
122
- this.done = this.done.bind(this)
123
- this.failures = 0
124
- this.process()
125
- }
208
+ function createReadStream (path, options) {
209
+ return new ReadStream(path, options)
210
+ }
126
211
 
127
- Req.prototype.done = function (er, result) {
128
- var tryAgain = false
129
- if (er) {
130
- var code = er.code
131
- var tryAgain = code === "EMFILE" || code === "ENFILE"
132
- if (process.platform === "win32")
133
- tryAgain = tryAgain || code === "OK"
212
+ function createWriteStream (path, options) {
213
+ return new WriteStream(path, options)
134
214
  }
135
215
 
136
- if (tryAgain) {
137
- this.failures ++
138
- enqueue(this)
139
- } else {
140
- var cb = this.cb
141
- cb(er, result)
216
+ var fs$open = fs.open
217
+ fs.open = open
218
+ function open (path, flags, mode, cb) {
219
+ if (typeof mode === 'function')
220
+ cb = mode, mode = null
221
+
222
+ return go$open(path, flags, mode, cb)
223
+
224
+ function go$open (path, flags, mode, cb) {
225
+ return fs$open(path, flags, mode, function (err, fd) {
226
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
227
+ enqueue([go$open, [path, flags, mode, cb]])
228
+ else {
229
+ if (typeof cb === 'function')
230
+ cb.apply(this, arguments)
231
+ retry()
232
+ }
233
+ })
234
+ }
142
235
  }
143
- }
144
236
 
145
- var queue = []
237
+ return fs
238
+ }
146
239
 
147
- function enqueue(req) {
148
- queue.push(req)
149
- debug('enqueue %d %s', queue.length, req.constructor.name, req)
240
+ function enqueue (elem) {
241
+ debug('ENQUEUE', elem[0].name, elem[1])
242
+ queue.push(elem)
150
243
  }
151
244
 
152
- function onclose() {
153
- var req = queue.shift()
154
- if (req) {
155
- debug('process', req.constructor.name, req)
156
- req.process()
245
+ function retry () {
246
+ var elem = queue.shift()
247
+ if (elem) {
248
+ debug('RETRY', elem[0].name, elem[1])
249
+ elem[0].apply(null, elem[1])
157
250
  }
158
251
  }
@@ -0,0 +1,118 @@
1
+ var Stream = require('stream').Stream
2
+
3
+ module.exports = legacy
4
+
5
+ function legacy (fs) {
6
+ return {
7
+ ReadStream: ReadStream,
8
+ WriteStream: WriteStream
9
+ }
10
+
11
+ function ReadStream (path, options) {
12
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
13
+
14
+ Stream.call(this);
15
+
16
+ var self = this;
17
+
18
+ this.path = path;
19
+ this.fd = null;
20
+ this.readable = true;
21
+ this.paused = false;
22
+
23
+ this.flags = 'r';
24
+ this.mode = 438; /*=0666*/
25
+ this.bufferSize = 64 * 1024;
26
+
27
+ options = options || {};
28
+
29
+ // Mixin options into this
30
+ var keys = Object.keys(options);
31
+ for (var index = 0, length = keys.length; index < length; index++) {
32
+ var key = keys[index];
33
+ this[key] = options[key];
34
+ }
35
+
36
+ if (this.encoding) this.setEncoding(this.encoding);
37
+
38
+ if (this.start !== undefined) {
39
+ if ('number' !== typeof this.start) {
40
+ throw TypeError('start must be a Number');
41
+ }
42
+ if (this.end === undefined) {
43
+ this.end = Infinity;
44
+ } else if ('number' !== typeof this.end) {
45
+ throw TypeError('end must be a Number');
46
+ }
47
+
48
+ if (this.start > this.end) {
49
+ throw new Error('start must be <= end');
50
+ }
51
+
52
+ this.pos = this.start;
53
+ }
54
+
55
+ if (this.fd !== null) {
56
+ process.nextTick(function() {
57
+ self._read();
58
+ });
59
+ return;
60
+ }
61
+
62
+ fs.open(this.path, this.flags, this.mode, function (err, fd) {
63
+ if (err) {
64
+ self.emit('error', err);
65
+ self.readable = false;
66
+ return;
67
+ }
68
+
69
+ self.fd = fd;
70
+ self.emit('open', fd);
71
+ self._read();
72
+ })
73
+ }
74
+
75
+ function WriteStream (path, options) {
76
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
77
+
78
+ Stream.call(this);
79
+
80
+ this.path = path;
81
+ this.fd = null;
82
+ this.writable = true;
83
+
84
+ this.flags = 'w';
85
+ this.encoding = 'binary';
86
+ this.mode = 438; /*=0666*/
87
+ this.bytesWritten = 0;
88
+
89
+ options = options || {};
90
+
91
+ // Mixin options into this
92
+ var keys = Object.keys(options);
93
+ for (var index = 0, length = keys.length; index < length; index++) {
94
+ var key = keys[index];
95
+ this[key] = options[key];
96
+ }
97
+
98
+ if (this.start !== undefined) {
99
+ if ('number' !== typeof this.start) {
100
+ throw TypeError('start must be a Number');
101
+ }
102
+ if (this.start < 0) {
103
+ throw new Error('start must be >= zero');
104
+ }
105
+
106
+ this.pos = this.start;
107
+ }
108
+
109
+ this.busy = false;
110
+ this._queue = [];
111
+
112
+ if (this.fd === null) {
113
+ this._open = fs.open;
114
+ this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
115
+ this.flush();
116
+ }
117
+ }
118
+ }
@@ -1,15 +1,10 @@
1
1
  {
2
- "author": {
3
- "name": "Isaac Z. Schlueter",
4
- "email": "i@izs.me",
5
- "url": "http://blog.izs.me"
6
- },
7
2
  "name": "graceful-fs",
8
3
  "description": "A drop-in replacement for fs, making various improvements.",
9
- "version": "3.0.8",
4
+ "version": "4.1.2",
10
5
  "repository": {
11
6
  "type": "git",
12
- "url": "git://github.com/isaacs/node-graceful-fs.git"
7
+ "url": "git+https://github.com/isaacs/node-graceful-fs.git"
13
8
  },
14
9
  "main": "graceful-fs.js",
15
10
  "engines": {
@@ -19,7 +14,7 @@
19
14
  "test": "test"
20
15
  },
21
16
  "scripts": {
22
- "test": "tap test/*.js"
17
+ "test": "node test.js | tap -"
23
18
  },
24
19
  "keywords": [
25
20
  "fs",
@@ -43,23 +38,29 @@
43
38
  "rimraf": "^2.2.8",
44
39
  "tap": "^1.2.0"
45
40
  },
46
- "gitHead": "45c57aa5e323c35a985a525de6f0c9a6ef59e1f8",
41
+ "files": [
42
+ "fs.js",
43
+ "graceful-fs.js",
44
+ "legacy-streams.js",
45
+ "polyfills.js"
46
+ ],
47
+ "gitHead": "c286080071b6be9aa9ba108b0bb9b44ff122926d",
47
48
  "bugs": {
48
49
  "url": "https://github.com/isaacs/node-graceful-fs/issues"
49
50
  },
50
51
  "homepage": "https://github.com/isaacs/node-graceful-fs#readme",
51
- "_id": "graceful-fs@3.0.8",
52
- "_shasum": "ce813e725fa82f7e6147d51c9a5ca68270551c22",
53
- "_from": "graceful-fs@3",
54
- "_npmVersion": "2.10.1",
55
- "_nodeVersion": "2.0.1",
52
+ "_id": "graceful-fs@4.1.2",
53
+ "_shasum": "fe2239b7574972e67e41f808823f9bfa4a991e37",
54
+ "_from": "graceful-fs@^4.1.2",
55
+ "_npmVersion": "3.0.0",
56
+ "_nodeVersion": "2.2.1",
56
57
  "_npmUser": {
57
58
  "name": "isaacs",
58
59
  "email": "isaacs@npmjs.com"
59
60
  },
60
61
  "dist": {
61
- "shasum": "ce813e725fa82f7e6147d51c9a5ca68270551c22",
62
- "tarball": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.8.tgz"
62
+ "shasum": "fe2239b7574972e67e41f808823f9bfa4a991e37",
63
+ "tarball": "http://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.2.tgz"
63
64
  },
64
65
  "maintainers": [
65
66
  {
@@ -67,6 +68,6 @@
67
68
  "email": "i@izs.me"
68
69
  }
69
70
  ],
70
- "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-3.0.8.tgz",
71
+ "_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.2.tgz",
71
72
  "readme": "ERROR: No README data found!"
72
73
  }