08-27-周三_17-09-29
This commit is contained in:
3
node_modules/klaw/.npmignore
generated
vendored
Normal file
3
node_modules/klaw/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
tests/
|
||||
appveyor.yml
|
||||
.travis.yml
|
42
node_modules/klaw/CHANGELOG.md
generated
vendored
Normal file
42
node_modules/klaw/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
1.3.1 / 2016-10-25
|
||||
------------------
|
||||
### Added
|
||||
- `graceful-fs` added as an `optionalDependencies`. Thanks [ryanzim]!
|
||||
|
||||
1.3.0 / 2016-06-09
|
||||
------------------
|
||||
### Added
|
||||
- `filter` option to pre-filter and not walk directories.
|
||||
|
||||
1.2.0 / 2016-04-16
|
||||
------------------
|
||||
- added support for custom `fs` implementation. Useful for https://github.com/tschaub/mock-fs
|
||||
|
||||
1.1.3 / 2015-12-23
|
||||
------------------
|
||||
- bugfix: if `readdir` error, got hung up. See: https://github.com/jprichardson/node-klaw/issues/1
|
||||
|
||||
1.1.2 / 2015-11-12
|
||||
------------------
|
||||
- assert that param `dir` is a `string`
|
||||
|
||||
1.1.1 / 2015-10-25
|
||||
------------------
|
||||
- bug fix, options not being passed
|
||||
|
||||
1.1.0 / 2015-10-25
|
||||
------------------
|
||||
- added `queueMethod` and `pathSorter` to `options` to affect searching strategy.
|
||||
|
||||
1.0.0 / 2015-10-25
|
||||
------------------
|
||||
- removed unused `filter` param
|
||||
- bugfix: always set `streamOptions` to `objectMode`
|
||||
- simplified, converted from push mode (streams 1) to proper pull mode (streams 3)
|
||||
|
||||
0.1.0 / 2015-10-25
|
||||
------------------
|
||||
- initial release
|
||||
|
||||
<!-- contributors -->
|
||||
[ryanzim]: https://github.com/ryanzim
|
15
node_modules/klaw/LICENSE
generated
vendored
Normal file
15
node_modules/klaw/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015-2016 JP Richardson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
|
||||
(the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
|
||||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
||||
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
270
node_modules/klaw/README.md
generated
vendored
Normal file
270
node_modules/klaw/README.md
generated
vendored
Normal file
@@ -0,0 +1,270 @@
|
||||
Node.js - klaw
|
||||
==============
|
||||
|
||||
A Node.js file system walker extracted from [fs-extra](https://github.com/jprichardson/node-fs-extra).
|
||||
|
||||
[](https://www.npmjs.org/package/klaw)
|
||||
[](http://travis-ci.org/jprichardson/node-klaw)
|
||||
[](https://ci.appveyor.com/project/jprichardson/node-klaw/branch/master)
|
||||
|
||||
<!-- [](https://github.com/feross/standard) -->
|
||||
<a href="http://standardjs.com"><img src="https://cdn.rawgit.com/feross/standard/master/sticker.svg" alt="Standard" width="100"></a>
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
npm i --save klaw
|
||||
|
||||
|
||||
Name
|
||||
----
|
||||
|
||||
`klaw` is `walk` backwards :p
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### klaw(directory, [options])
|
||||
|
||||
Returns a [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) that iterates
|
||||
through every file and directory starting with `dir` as the root. Every `read()` or `data` event
|
||||
returns an object with two properties: `path` and `stats`. `path` is the full path of the file and
|
||||
`stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).
|
||||
|
||||
- `directory`: The directory to recursively walk. Type `string`.
|
||||
- `options`: [Readable stream options](https://nodejs.org/api/stream.html#stream_new_stream_readable_options) and
|
||||
the following:
|
||||
- `queueMethod` (`string`, default: `'shift'`): Either `'shift'` or `'pop'`. On `readdir()` array, call either `shift()` or `pop()`.
|
||||
- `pathSorter` (`function`, default: `undefined`): Sorting [function for Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort).
|
||||
- `fs` (`object`, default: `require('fs')`): Use this to hook into the `fs` methods or to use [`mock-fs`](https://github.com/tschaub/mock-fs)
|
||||
- `filter` (`function`, default: `undefined`): Filtering [function for Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
|
||||
|
||||
**Streams 1 (push) example:**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
```
|
||||
|
||||
**Streams 2 & 3 (pull) example:**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.on('readable', function () {
|
||||
var item
|
||||
while ((item = this.read())) {
|
||||
items.push(item.path)
|
||||
}
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
```
|
||||
|
||||
If you're not sure of the differences on Node.js streams 1, 2, 3 then I'd
|
||||
recommend this resource as a good starting point: https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/.
|
||||
|
||||
|
||||
### Error Handling
|
||||
|
||||
Listen for the `error` event.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
klaw('/some/dir')
|
||||
.on('readable', function () {
|
||||
var item
|
||||
while ((item = this.read())) {
|
||||
// do something with the file
|
||||
}
|
||||
})
|
||||
.on('error', function (err, item) {
|
||||
console.log(err.message)
|
||||
console.log(item.path) // the file the error occurred on
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files]
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Aggregation / Filtering / Executing Actions (Through Streams)
|
||||
|
||||
On many occasions you may want to filter files based upon size, extension, etc.
|
||||
Or you may want to aggregate stats on certain file types. Or maybe you want to
|
||||
perform an action on certain file types.
|
||||
|
||||
You should use the module [`through2`](https://www.npmjs.com/package/through2) to easily
|
||||
accomplish this.
|
||||
|
||||
Install `through2`:
|
||||
|
||||
npm i --save through2
|
||||
|
||||
|
||||
**Example (skipping directories):**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var through2 = require('through2')
|
||||
|
||||
var excludeDirFilter = through2.obj(function (item, enc, next) {
|
||||
if (!item.stats.isDirectory()) this.push(item)
|
||||
next()
|
||||
})
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.pipe(excludeDirFilter)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files without directories]
|
||||
})
|
||||
|
||||
```
|
||||
**Example (ignore hidden directories):**
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var path = require('path')
|
||||
|
||||
var filterFunc = function(item){
|
||||
var basename = path.basename(item)
|
||||
return basename === '.' || basename[0] !== '.'
|
||||
}
|
||||
|
||||
klaw('/some/dir', { filter : filterFunc })
|
||||
.on('data', function(item){
|
||||
// only items of none hidden folders will reach here
|
||||
})
|
||||
|
||||
```
|
||||
|
||||
**Example (totaling size of PNG files):**
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var path = require('path')
|
||||
var through2 = require('through2')
|
||||
|
||||
var totalPngsInBytes = 0
|
||||
var aggregatePngSize = through2.obj(function (item, enc, next) {
|
||||
if (path.extname(item.path) === '.png') {
|
||||
totalPngsInBytes += item.stats.size
|
||||
}
|
||||
this.push(item)
|
||||
next()
|
||||
})
|
||||
|
||||
klaw('/some/dir')
|
||||
.pipe(aggregatePngSize)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(totalPngsInBytes) // => total of all pngs (bytes)
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
**Example (deleting all .tmp files):**
|
||||
|
||||
```js
|
||||
var fs = require('fs')
|
||||
var klaw = require('klaw')
|
||||
var through2 = require('through2')
|
||||
|
||||
var deleteAction = through2.obj(function (item, enc, next) {
|
||||
this.push(item)
|
||||
|
||||
if (path.extname(item.path) === '.tmp') {
|
||||
item.deleted = true
|
||||
fs.unklink(item.path, next)
|
||||
} else {
|
||||
item.deleted = false
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
var deletedFiles = []
|
||||
klaw('/some/dir')
|
||||
.pipe(deleteAction)
|
||||
.on('data', function (item) {
|
||||
if (!item.deleted) return
|
||||
deletedFiles.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(deletedFiles) // => all deleted files
|
||||
})
|
||||
```
|
||||
|
||||
You can even chain a bunch of these filters and aggregators together. By using
|
||||
multiple pipes.
|
||||
|
||||
**Example (using multiple filters / aggregators):**
|
||||
|
||||
```js
|
||||
klaw('/some/dir')
|
||||
.pipe(filterCertainFiles)
|
||||
.pipe(deleteSomeOtherFiles)
|
||||
.on('end', function () {
|
||||
console.log('all done!')
|
||||
})
|
||||
```
|
||||
|
||||
**Example passing (piping) through errors:**
|
||||
|
||||
Node.js does not `pipe()` errors. This means that the error on one stream, like
|
||||
`klaw` will not pipe through to the next. If you want to do this, do the following:
|
||||
|
||||
```js
|
||||
var klaw = require('klaw')
|
||||
var through2 = require('through2')
|
||||
|
||||
var excludeDirFilter = through2.obj(function (item, enc, next) {
|
||||
if (!item.stats.isDirectory()) this.push(item)
|
||||
next()
|
||||
})
|
||||
|
||||
var items = [] // files, directories, symlinks, etc
|
||||
klaw('/some/dir')
|
||||
.on('error', function (err) { excludeDirFilter.emit('error', err) }) // forward the error on
|
||||
.pipe(excludeDirFilter)
|
||||
.on('data', function (item) {
|
||||
items.push(item.path)
|
||||
})
|
||||
.on('end', function () {
|
||||
console.dir(items) // => [ ... array of files without directories]
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### Searching Strategy
|
||||
|
||||
Pass in options for `queueMethod` and `pathSorter` to affect how the file system
|
||||
is recursively iterated. See the code for more details, it's less than 50 lines :)
|
||||
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Copyright (c) 2015 [JP Richardson](https://github.com/jprichardson)
|
15
node_modules/klaw/node_modules/graceful-fs/LICENSE
generated
vendored
Normal file
15
node_modules/klaw/node_modules/graceful-fs/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
143
node_modules/klaw/node_modules/graceful-fs/README.md
generated
vendored
Normal file
143
node_modules/klaw/node_modules/graceful-fs/README.md
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
# graceful-fs
|
||||
|
||||
graceful-fs functions as a drop-in replacement for the fs module,
|
||||
making various improvements.
|
||||
|
||||
The improvements are meant to normalize behavior across different
|
||||
platforms and environments, and to make filesystem access more
|
||||
resilient to errors.
|
||||
|
||||
## Improvements over [fs module](https://nodejs.org/api/fs.html)
|
||||
|
||||
* Queues up `open` and `readdir` calls, and retries them once
|
||||
something closes if there is an EMFILE error from too many file
|
||||
descriptors.
|
||||
* fixes `lchmod` for Node versions prior to 0.6.2.
|
||||
* implements `fs.lutimes` if possible. Otherwise it becomes a noop.
|
||||
* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or
|
||||
`lchown` if the user isn't root.
|
||||
* makes `lchmod` and `lchown` become noops, if not available.
|
||||
* retries reading a file if `read` results in EAGAIN error.
|
||||
|
||||
On Windows, it retries renaming a file for up to one second if `EACCESS`
|
||||
or `EPERM` error occurs, likely because antivirus software has locked
|
||||
the directory.
|
||||
|
||||
## USAGE
|
||||
|
||||
```javascript
|
||||
// use just like fs
|
||||
var fs = require('graceful-fs')
|
||||
|
||||
// now go and do stuff with it...
|
||||
fs.readFile('some-file-or-whatever', (err, data) => {
|
||||
// Do stuff here.
|
||||
})
|
||||
```
|
||||
|
||||
## Sync methods
|
||||
|
||||
This module cannot intercept or handle `EMFILE` or `ENFILE` errors from sync
|
||||
methods. If you use sync methods which open file descriptors then you are
|
||||
responsible for dealing with any errors.
|
||||
|
||||
This is a known limitation, not a bug.
|
||||
|
||||
## Global Patching
|
||||
|
||||
If you want to patch the global fs module (or any other fs-like
|
||||
module) you can do this:
|
||||
|
||||
```javascript
|
||||
// Make sure to read the caveat below.
|
||||
var realFs = require('fs')
|
||||
var gracefulFs = require('graceful-fs')
|
||||
gracefulFs.gracefulify(realFs)
|
||||
```
|
||||
|
||||
This should only ever be done at the top-level application layer, in
|
||||
order to delay on EMFILE errors from any fs-using dependencies. You
|
||||
should **not** do this in a library, because it can cause unexpected
|
||||
delays in other parts of the program.
|
||||
|
||||
## Changes
|
||||
|
||||
This module is fairly stable at this point, and used by a lot of
|
||||
things. That being said, because it implements a subtle behavior
|
||||
change in a core part of the node API, even modest changes can be
|
||||
extremely breaking, and the versioning is thus biased towards
|
||||
bumping the major when in doubt.
|
||||
|
||||
The main change between major versions has been switching between
|
||||
providing a fully-patched `fs` module vs monkey-patching the node core
|
||||
builtin, and the approach by which a non-monkey-patched `fs` was
|
||||
created.
|
||||
|
||||
The goal is to trade `EMFILE` errors for slower fs operations. So, if
|
||||
you try to open a zillion files, rather than crashing, `open`
|
||||
operations will be queued up and wait for something else to `close`.
|
||||
|
||||
There are advantages to each approach. Monkey-patching the fs means
|
||||
that no `EMFILE` errors can possibly occur anywhere in your
|
||||
application, because everything is using the same core `fs` module,
|
||||
which is patched. However, it can also obviously cause undesirable
|
||||
side-effects, especially if the module is loaded multiple times.
|
||||
|
||||
Implementing a separate-but-identical patched `fs` module is more
|
||||
surgical (and doesn't run the risk of patching multiple times), but
|
||||
also imposes the challenge of keeping in sync with the core module.
|
||||
|
||||
The current approach loads the `fs` module, and then creates a
|
||||
lookalike object that has all the same methods, except a few that are
|
||||
patched. It is safe to use in all versions of Node from 0.8 through
|
||||
7.0.
|
||||
|
||||
### v4
|
||||
|
||||
* Do not monkey-patch the fs module. This module may now be used as a
|
||||
drop-in dep, and users can opt into monkey-patching the fs builtin
|
||||
if their app requires it.
|
||||
|
||||
### v3
|
||||
|
||||
* Monkey-patch fs, because the eval approach no longer works on recent
|
||||
node.
|
||||
* fixed possible type-error throw if rename fails on windows
|
||||
* verify that we *never* get EMFILE errors
|
||||
* Ignore ENOSYS from chmod/chown
|
||||
* clarify that graceful-fs must be used as a drop-in
|
||||
|
||||
### v2.1.0
|
||||
|
||||
* Use eval rather than monkey-patching fs.
|
||||
* readdir: Always sort the results
|
||||
* win32: requeue a file if error has an OK status
|
||||
|
||||
### v2.0
|
||||
|
||||
* A return to monkey patching
|
||||
* wrap process.cwd
|
||||
|
||||
### v1.1
|
||||
|
||||
* wrap readFile
|
||||
* Wrap fs.writeFile.
|
||||
* readdir protection
|
||||
* Don't clobber the fs builtin
|
||||
* Handle fs.read EAGAIN errors by trying again
|
||||
* Expose the curOpen counter
|
||||
* No-op lchown/lchmod if not implemented
|
||||
* fs.rename patch only for win32
|
||||
* Patch fs.rename to handle AV software on Windows
|
||||
* Close #4 Chown should not fail on einval or eperm if non-root
|
||||
* Fix isaacs/fstream#1 Only wrap fs one time
|
||||
* Fix #3 Start at 1024 max files, then back off on EMFILE
|
||||
* lutimes that doens't blow up on Linux
|
||||
* A full on-rewrite using a queue instead of just swallowing the EMFILE error
|
||||
* Wrap Read/Write streams as well
|
||||
|
||||
### 1.0
|
||||
|
||||
* Update engines for node 0.6
|
||||
* Be lstat-graceful on Windows
|
||||
* first
|
23
node_modules/klaw/node_modules/graceful-fs/clone.js
generated
vendored
Normal file
23
node_modules/klaw/node_modules/graceful-fs/clone.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = clone
|
||||
|
||||
var getPrototypeOf = Object.getPrototypeOf || function (obj) {
|
||||
return obj.__proto__
|
||||
}
|
||||
|
||||
function clone (obj) {
|
||||
if (obj === null || typeof obj !== 'object')
|
||||
return obj
|
||||
|
||||
if (obj instanceof Object)
|
||||
var copy = { __proto__: getPrototypeOf(obj) }
|
||||
else
|
||||
var copy = Object.create(null)
|
||||
|
||||
Object.getOwnPropertyNames(obj).forEach(function (key) {
|
||||
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
|
||||
})
|
||||
|
||||
return copy
|
||||
}
|
448
node_modules/klaw/node_modules/graceful-fs/graceful-fs.js
generated
vendored
Normal file
448
node_modules/klaw/node_modules/graceful-fs/graceful-fs.js
generated
vendored
Normal file
@@ -0,0 +1,448 @@
|
||||
var fs = require('fs')
|
||||
var polyfills = require('./polyfills.js')
|
||||
var legacy = require('./legacy-streams.js')
|
||||
var clone = require('./clone.js')
|
||||
|
||||
var util = require('util')
|
||||
|
||||
/* istanbul ignore next - node 0.x polyfill */
|
||||
var gracefulQueue
|
||||
var previousSymbol
|
||||
|
||||
/* istanbul ignore else - node 0.x polyfill */
|
||||
if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
|
||||
gracefulQueue = Symbol.for('graceful-fs.queue')
|
||||
// This is used in testing by future versions
|
||||
previousSymbol = Symbol.for('graceful-fs.previous')
|
||||
} else {
|
||||
gracefulQueue = '___graceful-fs.queue'
|
||||
previousSymbol = '___graceful-fs.previous'
|
||||
}
|
||||
|
||||
function noop () {}
|
||||
|
||||
function publishQueue(context, queue) {
|
||||
Object.defineProperty(context, gracefulQueue, {
|
||||
get: function() {
|
||||
return queue
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var debug = noop
|
||||
if (util.debuglog)
|
||||
debug = util.debuglog('gfs4')
|
||||
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
|
||||
debug = function() {
|
||||
var m = util.format.apply(util, arguments)
|
||||
m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ')
|
||||
console.error(m)
|
||||
}
|
||||
|
||||
// Once time initialization
|
||||
if (!fs[gracefulQueue]) {
|
||||
// This queue can be shared by multiple loaded instances
|
||||
var queue = global[gracefulQueue] || []
|
||||
publishQueue(fs, queue)
|
||||
|
||||
// Patch fs.close/closeSync to shared queue version, because we need
|
||||
// to retry() whenever a close happens *anywhere* in the program.
|
||||
// This is essential when multiple graceful-fs instances are
|
||||
// in play at the same time.
|
||||
fs.close = (function (fs$close) {
|
||||
function close (fd, cb) {
|
||||
return fs$close.call(fs, fd, function (err) {
|
||||
// This function uses the graceful-fs shared queue
|
||||
if (!err) {
|
||||
resetQueue()
|
||||
}
|
||||
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
|
||||
Object.defineProperty(close, previousSymbol, {
|
||||
value: fs$close
|
||||
})
|
||||
return close
|
||||
})(fs.close)
|
||||
|
||||
fs.closeSync = (function (fs$closeSync) {
|
||||
function closeSync (fd) {
|
||||
// This function uses the graceful-fs shared queue
|
||||
fs$closeSync.apply(fs, arguments)
|
||||
resetQueue()
|
||||
}
|
||||
|
||||
Object.defineProperty(closeSync, previousSymbol, {
|
||||
value: fs$closeSync
|
||||
})
|
||||
return closeSync
|
||||
})(fs.closeSync)
|
||||
|
||||
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
|
||||
process.on('exit', function() {
|
||||
debug(fs[gracefulQueue])
|
||||
require('assert').equal(fs[gracefulQueue].length, 0)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!global[gracefulQueue]) {
|
||||
publishQueue(global, fs[gracefulQueue]);
|
||||
}
|
||||
|
||||
module.exports = patch(clone(fs))
|
||||
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
||||
module.exports = patch(fs)
|
||||
fs.__patched = true;
|
||||
}
|
||||
|
||||
function patch (fs) {
|
||||
// Everything that references the open() function needs to be in here
|
||||
polyfills(fs)
|
||||
fs.gracefulify = patch
|
||||
|
||||
fs.createReadStream = createReadStream
|
||||
fs.createWriteStream = createWriteStream
|
||||
var fs$readFile = fs.readFile
|
||||
fs.readFile = readFile
|
||||
function readFile (path, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$readFile(path, options, cb)
|
||||
|
||||
function go$readFile (path, options, cb, startTime) {
|
||||
return fs$readFile(path, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$readFile, [path, options, cb], err, startTime || Date.now(), Date.now()])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$writeFile = fs.writeFile
|
||||
fs.writeFile = writeFile
|
||||
function writeFile (path, data, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$writeFile(path, data, options, cb)
|
||||
|
||||
function go$writeFile (path, data, options, cb, startTime) {
|
||||
return fs$writeFile(path, data, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$writeFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$appendFile = fs.appendFile
|
||||
if (fs$appendFile)
|
||||
fs.appendFile = appendFile
|
||||
function appendFile (path, data, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
return go$appendFile(path, data, options, cb)
|
||||
|
||||
function go$appendFile (path, data, options, cb, startTime) {
|
||||
return fs$appendFile(path, data, options, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$appendFile, [path, data, options, cb], err, startTime || Date.now(), Date.now()])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$copyFile = fs.copyFile
|
||||
if (fs$copyFile)
|
||||
fs.copyFile = copyFile
|
||||
function copyFile (src, dest, flags, cb) {
|
||||
if (typeof flags === 'function') {
|
||||
cb = flags
|
||||
flags = 0
|
||||
}
|
||||
return go$copyFile(src, dest, flags, cb)
|
||||
|
||||
function go$copyFile (src, dest, flags, cb, startTime) {
|
||||
return fs$copyFile(src, dest, flags, function (err) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$copyFile, [src, dest, flags, cb], err, startTime || Date.now(), Date.now()])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var fs$readdir = fs.readdir
|
||||
fs.readdir = readdir
|
||||
var noReaddirOptionVersions = /^v[0-5]\./
|
||||
function readdir (path, options, cb) {
|
||||
if (typeof options === 'function')
|
||||
cb = options, options = null
|
||||
|
||||
var go$readdir = noReaddirOptionVersions.test(process.version)
|
||||
? function go$readdir (path, options, cb, startTime) {
|
||||
return fs$readdir(path, fs$readdirCallback(
|
||||
path, options, cb, startTime
|
||||
))
|
||||
}
|
||||
: function go$readdir (path, options, cb, startTime) {
|
||||
return fs$readdir(path, options, fs$readdirCallback(
|
||||
path, options, cb, startTime
|
||||
))
|
||||
}
|
||||
|
||||
return go$readdir(path, options, cb)
|
||||
|
||||
function fs$readdirCallback (path, options, cb, startTime) {
|
||||
return function (err, files) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([
|
||||
go$readdir,
|
||||
[path, options, cb],
|
||||
err,
|
||||
startTime || Date.now(),
|
||||
Date.now()
|
||||
])
|
||||
else {
|
||||
if (files && files.sort)
|
||||
files.sort()
|
||||
|
||||
if (typeof cb === 'function')
|
||||
cb.call(this, err, files)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (process.version.substr(0, 4) === 'v0.8') {
|
||||
var legStreams = legacy(fs)
|
||||
ReadStream = legStreams.ReadStream
|
||||
WriteStream = legStreams.WriteStream
|
||||
}
|
||||
|
||||
var fs$ReadStream = fs.ReadStream
|
||||
if (fs$ReadStream) {
|
||||
ReadStream.prototype = Object.create(fs$ReadStream.prototype)
|
||||
ReadStream.prototype.open = ReadStream$open
|
||||
}
|
||||
|
||||
var fs$WriteStream = fs.WriteStream
|
||||
if (fs$WriteStream) {
|
||||
WriteStream.prototype = Object.create(fs$WriteStream.prototype)
|
||||
WriteStream.prototype.open = WriteStream$open
|
||||
}
|
||||
|
||||
Object.defineProperty(fs, 'ReadStream', {
|
||||
get: function () {
|
||||
return ReadStream
|
||||
},
|
||||
set: function (val) {
|
||||
ReadStream = val
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
Object.defineProperty(fs, 'WriteStream', {
|
||||
get: function () {
|
||||
return WriteStream
|
||||
},
|
||||
set: function (val) {
|
||||
WriteStream = val
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
|
||||
// legacy names
|
||||
var FileReadStream = ReadStream
|
||||
Object.defineProperty(fs, 'FileReadStream', {
|
||||
get: function () {
|
||||
return FileReadStream
|
||||
},
|
||||
set: function (val) {
|
||||
FileReadStream = val
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
var FileWriteStream = WriteStream
|
||||
Object.defineProperty(fs, 'FileWriteStream', {
|
||||
get: function () {
|
||||
return FileWriteStream
|
||||
},
|
||||
set: function (val) {
|
||||
FileWriteStream = val
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
})
|
||||
|
||||
function ReadStream (path, options) {
|
||||
if (this instanceof ReadStream)
|
||||
return fs$ReadStream.apply(this, arguments), this
|
||||
else
|
||||
return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
|
||||
}
|
||||
|
||||
function ReadStream$open () {
|
||||
var that = this
|
||||
open(that.path, that.flags, that.mode, function (err, fd) {
|
||||
if (err) {
|
||||
if (that.autoClose)
|
||||
that.destroy()
|
||||
|
||||
that.emit('error', err)
|
||||
} else {
|
||||
that.fd = fd
|
||||
that.emit('open', fd)
|
||||
that.read()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function WriteStream (path, options) {
|
||||
if (this instanceof WriteStream)
|
||||
return fs$WriteStream.apply(this, arguments), this
|
||||
else
|
||||
return WriteStream.apply(Object.create(WriteStream.prototype), arguments)
|
||||
}
|
||||
|
||||
function WriteStream$open () {
|
||||
var that = this
|
||||
open(that.path, that.flags, that.mode, function (err, fd) {
|
||||
if (err) {
|
||||
that.destroy()
|
||||
that.emit('error', err)
|
||||
} else {
|
||||
that.fd = fd
|
||||
that.emit('open', fd)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function createReadStream (path, options) {
|
||||
return new fs.ReadStream(path, options)
|
||||
}
|
||||
|
||||
function createWriteStream (path, options) {
|
||||
return new fs.WriteStream(path, options)
|
||||
}
|
||||
|
||||
var fs$open = fs.open
|
||||
fs.open = open
|
||||
function open (path, flags, mode, cb) {
|
||||
if (typeof mode === 'function')
|
||||
cb = mode, mode = null
|
||||
|
||||
return go$open(path, flags, mode, cb)
|
||||
|
||||
function go$open (path, flags, mode, cb, startTime) {
|
||||
return fs$open(path, flags, mode, function (err, fd) {
|
||||
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
|
||||
enqueue([go$open, [path, flags, mode, cb], err, startTime || Date.now(), Date.now()])
|
||||
else {
|
||||
if (typeof cb === 'function')
|
||||
cb.apply(this, arguments)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return fs
|
||||
}
|
||||
|
||||
function enqueue (elem) {
|
||||
debug('ENQUEUE', elem[0].name, elem[1])
|
||||
fs[gracefulQueue].push(elem)
|
||||
retry()
|
||||
}
|
||||
|
||||
// keep track of the timeout between retry() calls
|
||||
var retryTimer
|
||||
|
||||
// reset the startTime and lastTime to now
|
||||
// this resets the start of the 60 second overall timeout as well as the
|
||||
// delay between attempts so that we'll retry these jobs sooner
|
||||
function resetQueue () {
|
||||
var now = Date.now()
|
||||
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
|
||||
// entries that are only a length of 2 are from an older version, don't
|
||||
// bother modifying those since they'll be retried anyway.
|
||||
if (fs[gracefulQueue][i].length > 2) {
|
||||
fs[gracefulQueue][i][3] = now // startTime
|
||||
fs[gracefulQueue][i][4] = now // lastTime
|
||||
}
|
||||
}
|
||||
// call retry to make sure we're actively processing the queue
|
||||
retry()
|
||||
}
|
||||
|
||||
function retry () {
|
||||
// clear the timer and remove it to help prevent unintended concurrency
|
||||
clearTimeout(retryTimer)
|
||||
retryTimer = undefined
|
||||
|
||||
if (fs[gracefulQueue].length === 0)
|
||||
return
|
||||
|
||||
var elem = fs[gracefulQueue].shift()
|
||||
var fn = elem[0]
|
||||
var args = elem[1]
|
||||
// these items may be unset if they were added by an older graceful-fs
|
||||
var err = elem[2]
|
||||
var startTime = elem[3]
|
||||
var lastTime = elem[4]
|
||||
|
||||
// if we don't have a startTime we have no way of knowing if we've waited
|
||||
// long enough, so go ahead and retry this item now
|
||||
if (startTime === undefined) {
|
||||
debug('RETRY', fn.name, args)
|
||||
fn.apply(null, args)
|
||||
} else if (Date.now() - startTime >= 60000) {
|
||||
// it's been more than 60 seconds total, bail now
|
||||
debug('TIMEOUT', fn.name, args)
|
||||
var cb = args.pop()
|
||||
if (typeof cb === 'function')
|
||||
cb.call(null, err)
|
||||
} else {
|
||||
// the amount of time between the last attempt and right now
|
||||
var sinceAttempt = Date.now() - lastTime
|
||||
// the amount of time between when we first tried, and when we last tried
|
||||
// rounded up to at least 1
|
||||
var sinceStart = Math.max(lastTime - startTime, 1)
|
||||
// backoff. wait longer than the total time we've been retrying, but only
|
||||
// up to a maximum of 100ms
|
||||
var desiredDelay = Math.min(sinceStart * 1.2, 100)
|
||||
// it's been long enough since the last retry, do it again
|
||||
if (sinceAttempt >= desiredDelay) {
|
||||
debug('RETRY', fn.name, args)
|
||||
fn.apply(null, args.concat([startTime]))
|
||||
} else {
|
||||
// if we can't do this job yet, push it to the end of the queue
|
||||
// and let the next iteration check again
|
||||
fs[gracefulQueue].push(elem)
|
||||
}
|
||||
}
|
||||
|
||||
// schedule our next run if one isn't already scheduled
|
||||
if (retryTimer === undefined) {
|
||||
retryTimer = setTimeout(retry, 0)
|
||||
}
|
||||
}
|
118
node_modules/klaw/node_modules/graceful-fs/legacy-streams.js
generated
vendored
Normal file
118
node_modules/klaw/node_modules/graceful-fs/legacy-streams.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
var Stream = require('stream').Stream
|
||||
|
||||
module.exports = legacy
|
||||
|
||||
function legacy (fs) {
|
||||
return {
|
||||
ReadStream: ReadStream,
|
||||
WriteStream: WriteStream
|
||||
}
|
||||
|
||||
function ReadStream (path, options) {
|
||||
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
||||
|
||||
Stream.call(this);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.path = path;
|
||||
this.fd = null;
|
||||
this.readable = true;
|
||||
this.paused = false;
|
||||
|
||||
this.flags = 'r';
|
||||
this.mode = 438; /*=0666*/
|
||||
this.bufferSize = 64 * 1024;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Mixin options into this
|
||||
var keys = Object.keys(options);
|
||||
for (var index = 0, length = keys.length; index < length; index++) {
|
||||
var key = keys[index];
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (this.encoding) this.setEncoding(this.encoding);
|
||||
|
||||
if (this.start !== undefined) {
|
||||
if ('number' !== typeof this.start) {
|
||||
throw TypeError('start must be a Number');
|
||||
}
|
||||
if (this.end === undefined) {
|
||||
this.end = Infinity;
|
||||
} else if ('number' !== typeof this.end) {
|
||||
throw TypeError('end must be a Number');
|
||||
}
|
||||
|
||||
if (this.start > this.end) {
|
||||
throw new Error('start must be <= end');
|
||||
}
|
||||
|
||||
this.pos = this.start;
|
||||
}
|
||||
|
||||
if (this.fd !== null) {
|
||||
process.nextTick(function() {
|
||||
self._read();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
fs.open(this.path, this.flags, this.mode, function (err, fd) {
|
||||
if (err) {
|
||||
self.emit('error', err);
|
||||
self.readable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
self.fd = fd;
|
||||
self.emit('open', fd);
|
||||
self._read();
|
||||
})
|
||||
}
|
||||
|
||||
function WriteStream (path, options) {
|
||||
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
||||
|
||||
Stream.call(this);
|
||||
|
||||
this.path = path;
|
||||
this.fd = null;
|
||||
this.writable = true;
|
||||
|
||||
this.flags = 'w';
|
||||
this.encoding = 'binary';
|
||||
this.mode = 438; /*=0666*/
|
||||
this.bytesWritten = 0;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Mixin options into this
|
||||
var keys = Object.keys(options);
|
||||
for (var index = 0, length = keys.length; index < length; index++) {
|
||||
var key = keys[index];
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (this.start !== undefined) {
|
||||
if ('number' !== typeof this.start) {
|
||||
throw TypeError('start must be a Number');
|
||||
}
|
||||
if (this.start < 0) {
|
||||
throw new Error('start must be >= zero');
|
||||
}
|
||||
|
||||
this.pos = this.start;
|
||||
}
|
||||
|
||||
this.busy = false;
|
||||
this._queue = [];
|
||||
|
||||
if (this.fd === null) {
|
||||
this._open = fs.open;
|
||||
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
||||
this.flush();
|
||||
}
|
||||
}
|
||||
}
|
131
node_modules/klaw/node_modules/graceful-fs/package.json
generated
vendored
Normal file
131
node_modules/klaw/node_modules/graceful-fs/package.json
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "graceful-fs",
|
||||
"raw": "graceful-fs@^4.1.2",
|
||||
"rawSpec": "^4.1.2",
|
||||
"scope": null,
|
||||
"spec": ">=4.1.2 <5.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/root/gitbook/node_modules/fs-extra"
|
||||
],
|
||||
[
|
||||
{
|
||||
"name": "graceful-fs",
|
||||
"raw": "graceful-fs@^4.1.9",
|
||||
"rawSpec": "^4.1.9",
|
||||
"scope": null,
|
||||
"spec": ">=4.1.9 <5.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/root/gitbook/node_modules/klaw"
|
||||
]
|
||||
],
|
||||
"_from": "graceful-fs@^4.1.9",
|
||||
"_hasShrinkwrap": false,
|
||||
"_id": "graceful-fs@4.2.11",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/klaw/graceful-fs",
|
||||
"_nodeVersion": "18.14.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/graceful-fs_4.2.11_1678995019142_0.5673425576033098"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "i@izs.me",
|
||||
"name": "isaacs"
|
||||
},
|
||||
"_npmVersion": "9.5.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "graceful-fs",
|
||||
"raw": "graceful-fs@^4.1.9",
|
||||
"rawSpec": "^4.1.9",
|
||||
"scope": null,
|
||||
"spec": ">=4.1.9 <5.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/klaw"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
"_shasum": "4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "graceful-fs@^4.1.9",
|
||||
"_where": "/root/gitbook/node_modules/klaw",
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-graceful-fs/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "A drop-in replacement for fs, making various improvements.",
|
||||
"devDependencies": {
|
||||
"import-fresh": "^2.0.0",
|
||||
"mkdirp": "^0.5.0",
|
||||
"rimraf": "^2.2.8",
|
||||
"tap": "^16.3.4"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"dist": {
|
||||
"fileCount": 7,
|
||||
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
||||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkE25LACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo1Cw/+N8TlrsFr9s7NQc7VlIFHMU2rKzP4vToGXmp36eSQFnl6ovT2\r\nORy24D9wbXLJHjoK3OXXfJj05y29v8qiNIEVpSxrULuRhvK49Ck3KkOl8uCg\r\n8gmXQCDCnY3n4MsEQgiUH34r+xJHE1szyaO4asFcfoDWJzq+YkLX2bbNfgow\r\n2Qrv+cuqOJVT2jVXRieFhJd5FWCD9Y4U+nzzY39a+UzvJvpq30lhRgTqZfNW\r\nct6GJx6Td8Kvc5SQ+EwAiFTrp8DUfZrzqD+U+E/GuMLLj3bCczYCagndUU27\r\nf1PNUMkqeTFpjuduqsQQuyyoLFm6cvKU4llHOETAaVTZpUPS6iR9SE91cuQt\r\n+ABAuaxuGuEmLWWBSbaPeOI76+CJAQ4mjwwFEwRSPTUY7wfCuhis4YBzEISD\r\nrDwkGKXwQ2XpLymE9QMAAFc6mxO1WxRbnlaxgmZLBhJGKeRh7KRaQRtI0qIy\r\nPm6M2Tpp+JoFOFIKy5Q8AldLlWWL5zzo71jglrQrGytDwem1sYjGDozXfVgm\r\nfYFO4SV4y0gXeY2Z68y0g+S4BmP+JUWM5v4WCBJxm1gEmEzz4yLv7PXVx12R\r\n10binyrgUoOUUWC7qSeQaVwROIQI8dNhOjSvdOJ3Vlpk2+cebpStOgJ9/eyY\r\nX1M50AoJmZh/Yl4oqHc8jSU5i9HjwWGe4zE=\r\n=HvMs\r\n-----END PGP SIGNATURE-----\r\n",
|
||||
"shasum": "4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3",
|
||||
"signatures": [
|
||||
{
|
||||
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
|
||||
"sig": "MEQCIGvrVOcn7hI1H803c2vtwpp2SWqq+i4Io7slvfmq5ALwAiBUkAIGXz4UnL+r6Mp2H+OE2q0DUtrViYowDGL171hm5w=="
|
||||
}
|
||||
],
|
||||
"tarball": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||
"unpackedSize": 32535
|
||||
},
|
||||
"gitHead": "514861c372899df14beb7aaecca4cdbb498d7d11",
|
||||
"homepage": "https://github.com/isaacs/node-graceful-fs#readme",
|
||||
"keywords": [
|
||||
"fs",
|
||||
"module",
|
||||
"reading",
|
||||
"retry",
|
||||
"retries",
|
||||
"queue",
|
||||
"error",
|
||||
"errors",
|
||||
"handling",
|
||||
"EMFILE",
|
||||
"EAGAIN",
|
||||
"EINVAL",
|
||||
"EPERM",
|
||||
"EACCESS"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "graceful-fs.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "i@izs.me",
|
||||
"name": "isaacs"
|
||||
}
|
||||
],
|
||||
"name": "graceful-fs",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/node-graceful-fs.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "git push origin --follow-tags",
|
||||
"posttest": "nyc report",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"test": "nyc --silent node test.js | tap -c -"
|
||||
},
|
||||
"tap": {
|
||||
"reporter": "classic"
|
||||
},
|
||||
"version": "4.2.11"
|
||||
}
|
355
node_modules/klaw/node_modules/graceful-fs/polyfills.js
generated
vendored
Normal file
355
node_modules/klaw/node_modules/graceful-fs/polyfills.js
generated
vendored
Normal file
@@ -0,0 +1,355 @@
|
||||
var constants = require('constants')
|
||||
|
||||
var origCwd = process.cwd
|
||||
var cwd = null
|
||||
|
||||
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform
|
||||
|
||||
process.cwd = function() {
|
||||
if (!cwd)
|
||||
cwd = origCwd.call(process)
|
||||
return cwd
|
||||
}
|
||||
try {
|
||||
process.cwd()
|
||||
} catch (er) {}
|
||||
|
||||
// This check is needed until node.js 12 is required
|
||||
if (typeof process.chdir === 'function') {
|
||||
var chdir = process.chdir
|
||||
process.chdir = function (d) {
|
||||
cwd = null
|
||||
chdir.call(process, d)
|
||||
}
|
||||
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir)
|
||||
}
|
||||
|
||||
module.exports = patch
|
||||
|
||||
function patch (fs) {
|
||||
// (re-)implement some things that are known busted or missing.
|
||||
|
||||
// lchmod, broken prior to 0.6.2
|
||||
// back-port the fix here.
|
||||
if (constants.hasOwnProperty('O_SYMLINK') &&
|
||||
process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
||||
patchLchmod(fs)
|
||||
}
|
||||
|
||||
// lutimes implementation, or no-op
|
||||
if (!fs.lutimes) {
|
||||
patchLutimes(fs)
|
||||
}
|
||||
|
||||
// https://github.com/isaacs/node-graceful-fs/issues/4
|
||||
// Chown should not fail on einval or eperm if non-root.
|
||||
// It should not fail on enosys ever, as this just indicates
|
||||
// that a fs doesn't support the intended operation.
|
||||
|
||||
fs.chown = chownFix(fs.chown)
|
||||
fs.fchown = chownFix(fs.fchown)
|
||||
fs.lchown = chownFix(fs.lchown)
|
||||
|
||||
fs.chmod = chmodFix(fs.chmod)
|
||||
fs.fchmod = chmodFix(fs.fchmod)
|
||||
fs.lchmod = chmodFix(fs.lchmod)
|
||||
|
||||
fs.chownSync = chownFixSync(fs.chownSync)
|
||||
fs.fchownSync = chownFixSync(fs.fchownSync)
|
||||
fs.lchownSync = chownFixSync(fs.lchownSync)
|
||||
|
||||
fs.chmodSync = chmodFixSync(fs.chmodSync)
|
||||
fs.fchmodSync = chmodFixSync(fs.fchmodSync)
|
||||
fs.lchmodSync = chmodFixSync(fs.lchmodSync)
|
||||
|
||||
fs.stat = statFix(fs.stat)
|
||||
fs.fstat = statFix(fs.fstat)
|
||||
fs.lstat = statFix(fs.lstat)
|
||||
|
||||
fs.statSync = statFixSync(fs.statSync)
|
||||
fs.fstatSync = statFixSync(fs.fstatSync)
|
||||
fs.lstatSync = statFixSync(fs.lstatSync)
|
||||
|
||||
// if lchmod/lchown do not exist, then make them no-ops
|
||||
if (fs.chmod && !fs.lchmod) {
|
||||
fs.lchmod = function (path, mode, cb) {
|
||||
if (cb) process.nextTick(cb)
|
||||
}
|
||||
fs.lchmodSync = function () {}
|
||||
}
|
||||
if (fs.chown && !fs.lchown) {
|
||||
fs.lchown = function (path, uid, gid, cb) {
|
||||
if (cb) process.nextTick(cb)
|
||||
}
|
||||
fs.lchownSync = function () {}
|
||||
}
|
||||
|
||||
// on Windows, A/V software can lock the directory, causing this
|
||||
// to fail with an EACCES or EPERM if the directory contains newly
|
||||
// created files. Try again on failure, for up to 60 seconds.
|
||||
|
||||
// Set the timeout this long because some Windows Anti-Virus, such as Parity
|
||||
// bit9, may lock files for up to a minute, causing npm package install
|
||||
// failures. Also, take care to yield the scheduler. Windows scheduling gives
|
||||
// CPU to a busy looping process, which can cause the program causing the lock
|
||||
// contention to be starved of CPU by node, so the contention doesn't resolve.
|
||||
if (platform === "win32") {
|
||||
fs.rename = typeof fs.rename !== 'function' ? fs.rename
|
||||
: (function (fs$rename) {
|
||||
function rename (from, to, cb) {
|
||||
var start = Date.now()
|
||||
var backoff = 0;
|
||||
fs$rename(from, to, function CB (er) {
|
||||
if (er
|
||||
&& (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY")
|
||||
&& Date.now() - start < 60000) {
|
||||
setTimeout(function() {
|
||||
fs.stat(to, function (stater, st) {
|
||||
if (stater && stater.code === "ENOENT")
|
||||
fs$rename(from, to, CB);
|
||||
else
|
||||
cb(er)
|
||||
})
|
||||
}, backoff)
|
||||
if (backoff < 100)
|
||||
backoff += 10;
|
||||
return;
|
||||
}
|
||||
if (cb) cb(er)
|
||||
})
|
||||
}
|
||||
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename)
|
||||
return rename
|
||||
})(fs.rename)
|
||||
}
|
||||
|
||||
// if read() returns EAGAIN, then just try it again.
|
||||
fs.read = typeof fs.read !== 'function' ? fs.read
|
||||
: (function (fs$read) {
|
||||
function read (fd, buffer, offset, length, position, callback_) {
|
||||
var callback
|
||||
if (callback_ && typeof callback_ === 'function') {
|
||||
var eagCounter = 0
|
||||
callback = function (er, _, __) {
|
||||
if (er && er.code === 'EAGAIN' && eagCounter < 10) {
|
||||
eagCounter ++
|
||||
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
||||
}
|
||||
callback_.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
return fs$read.call(fs, fd, buffer, offset, length, position, callback)
|
||||
}
|
||||
|
||||
// This ensures `util.promisify` works as it does for native `fs.read`.
|
||||
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read)
|
||||
return read
|
||||
})(fs.read)
|
||||
|
||||
fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync
|
||||
: (function (fs$readSync) { return function (fd, buffer, offset, length, position) {
|
||||
var eagCounter = 0
|
||||
while (true) {
|
||||
try {
|
||||
return fs$readSync.call(fs, fd, buffer, offset, length, position)
|
||||
} catch (er) {
|
||||
if (er.code === 'EAGAIN' && eagCounter < 10) {
|
||||
eagCounter ++
|
||||
continue
|
||||
}
|
||||
throw er
|
||||
}
|
||||
}
|
||||
}})(fs.readSync)
|
||||
|
||||
function patchLchmod (fs) {
|
||||
fs.lchmod = function (path, mode, callback) {
|
||||
fs.open( path
|
||||
, constants.O_WRONLY | constants.O_SYMLINK
|
||||
, mode
|
||||
, function (err, fd) {
|
||||
if (err) {
|
||||
if (callback) callback(err)
|
||||
return
|
||||
}
|
||||
// prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
fs.fchmod(fd, mode, function (err) {
|
||||
fs.close(fd, function(err2) {
|
||||
if (callback) callback(err || err2)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fs.lchmodSync = function (path, mode) {
|
||||
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode)
|
||||
|
||||
// prefer to return the chmod error, if one occurs,
|
||||
// but still try to close, and report closing errors if they occur.
|
||||
var threw = true
|
||||
var ret
|
||||
try {
|
||||
ret = fs.fchmodSync(fd, mode)
|
||||
threw = false
|
||||
} finally {
|
||||
if (threw) {
|
||||
try {
|
||||
fs.closeSync(fd)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
function patchLutimes (fs) {
|
||||
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
|
||||
fs.lutimes = function (path, at, mt, cb) {
|
||||
fs.open(path, constants.O_SYMLINK, function (er, fd) {
|
||||
if (er) {
|
||||
if (cb) cb(er)
|
||||
return
|
||||
}
|
||||
fs.futimes(fd, at, mt, function (er) {
|
||||
fs.close(fd, function (er2) {
|
||||
if (cb) cb(er || er2)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fs.lutimesSync = function (path, at, mt) {
|
||||
var fd = fs.openSync(path, constants.O_SYMLINK)
|
||||
var ret
|
||||
var threw = true
|
||||
try {
|
||||
ret = fs.futimesSync(fd, at, mt)
|
||||
threw = false
|
||||
} finally {
|
||||
if (threw) {
|
||||
try {
|
||||
fs.closeSync(fd)
|
||||
} catch (er) {}
|
||||
} else {
|
||||
fs.closeSync(fd)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
} else if (fs.futimes) {
|
||||
fs.lutimes = function (_a, _b, _c, cb) { if (cb) process.nextTick(cb) }
|
||||
fs.lutimesSync = function () {}
|
||||
}
|
||||
}
|
||||
|
||||
function chmodFix (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, mode, cb) {
|
||||
return orig.call(fs, target, mode, function (er) {
|
||||
if (chownErOk(er)) er = null
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function chmodFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, mode) {
|
||||
try {
|
||||
return orig.call(fs, target, mode)
|
||||
} catch (er) {
|
||||
if (!chownErOk(er)) throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function chownFix (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, uid, gid, cb) {
|
||||
return orig.call(fs, target, uid, gid, function (er) {
|
||||
if (chownErOk(er)) er = null
|
||||
if (cb) cb.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function chownFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
return function (target, uid, gid) {
|
||||
try {
|
||||
return orig.call(fs, target, uid, gid)
|
||||
} catch (er) {
|
||||
if (!chownErOk(er)) throw er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function statFix (orig) {
|
||||
if (!orig) return orig
|
||||
// Older versions of Node erroneously returned signed integers for
|
||||
// uid + gid.
|
||||
return function (target, options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options
|
||||
options = null
|
||||
}
|
||||
function callback (er, stats) {
|
||||
if (stats) {
|
||||
if (stats.uid < 0) stats.uid += 0x100000000
|
||||
if (stats.gid < 0) stats.gid += 0x100000000
|
||||
}
|
||||
if (cb) cb.apply(this, arguments)
|
||||
}
|
||||
return options ? orig.call(fs, target, options, callback)
|
||||
: orig.call(fs, target, callback)
|
||||
}
|
||||
}
|
||||
|
||||
function statFixSync (orig) {
|
||||
if (!orig) return orig
|
||||
// Older versions of Node erroneously returned signed integers for
|
||||
// uid + gid.
|
||||
return function (target, options) {
|
||||
var stats = options ? orig.call(fs, target, options)
|
||||
: orig.call(fs, target)
|
||||
if (stats) {
|
||||
if (stats.uid < 0) stats.uid += 0x100000000
|
||||
if (stats.gid < 0) stats.gid += 0x100000000
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
}
|
||||
|
||||
// ENOSYS means that the fs doesn't support the op. Just ignore
|
||||
// that, because it doesn't matter.
|
||||
//
|
||||
// if there's no getuid, or if getuid() is something other
|
||||
// than 0, and the error is EINVAL or EPERM, then just ignore
|
||||
// it.
|
||||
//
|
||||
// This specific case is a silent failure in cp, install, tar,
|
||||
// and most other unix tools that manage permissions.
|
||||
//
|
||||
// When running as root, or if other types of errors are
|
||||
// encountered, then it's strict.
|
||||
function chownErOk (er) {
|
||||
if (!er)
|
||||
return true
|
||||
|
||||
if (er.code === "ENOSYS")
|
||||
return true
|
||||
|
||||
var nonroot = !process.getuid || process.getuid() !== 0
|
||||
if (nonroot) {
|
||||
if (er.code === "EINVAL" || er.code === "EPERM")
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
110
node_modules/klaw/package.json
generated
vendored
Normal file
110
node_modules/klaw/package.json
generated
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "klaw",
|
||||
"raw": "klaw@^1.0.0",
|
||||
"rawSpec": "^1.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/root/gitbook/node_modules/fs-extra"
|
||||
]
|
||||
],
|
||||
"_from": "klaw@>=1.0.0 <2.0.0",
|
||||
"_id": "klaw@1.3.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/klaw",
|
||||
"_nodeVersion": "6.5.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-18-east.internal.npmjs.com",
|
||||
"tmp": "tmp/klaw-1.3.1.tgz_1477411628636_0.7360875811427832"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "jprichardson@gmail.com",
|
||||
"name": "jprichardson"
|
||||
},
|
||||
"_npmVersion": "3.10.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "klaw",
|
||||
"raw": "klaw@^1.0.0",
|
||||
"rawSpec": "^1.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/fs-extra"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz",
|
||||
"_shasum": "4088433b46b3b1ba259d78785d8e96f73ba02439",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "klaw@^1.0.0",
|
||||
"_where": "/root/gitbook/node_modules/fs-extra",
|
||||
"author": {
|
||||
"name": "JP Richardson"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jprichardson/node-klaw/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.1.9"
|
||||
},
|
||||
"description": "File system walker with Readable stream interface.",
|
||||
"devDependencies": {
|
||||
"mkdirp": "^0.5.1",
|
||||
"mock-fs": "^3.8.0",
|
||||
"rimraf": "^2.4.3",
|
||||
"standard": "^8.4.0",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.2.2"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw==",
|
||||
"shasum": "4088433b46b3b1ba259d78785d8e96f73ba02439",
|
||||
"signatures": [
|
||||
{
|
||||
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
|
||||
"sig": "MEYCIQDvspwmHLkW9T+5HZjoel3O6RtC/7CiCePvJs5HTjC3ogIhAL2gy2wDE4MgSCYXjCgbys0cHEXpmy3GTLq+F/0mLaGX"
|
||||
}
|
||||
],
|
||||
"tarball": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz"
|
||||
},
|
||||
"gitHead": "7ceea730d54726affeaca62d6e362db0b6881f93",
|
||||
"homepage": "https://github.com/jprichardson/node-klaw#readme",
|
||||
"keywords": [
|
||||
"walk",
|
||||
"walker",
|
||||
"fs",
|
||||
"fs-extra",
|
||||
"readable",
|
||||
"streams"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./src/index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "jprichardson@gmail.com",
|
||||
"name": "jprichardson"
|
||||
}
|
||||
],
|
||||
"name": "klaw",
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.9"
|
||||
},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jprichardson/node-klaw.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"test": "npm run lint && npm run unit",
|
||||
"unit": "tape tests/**/*.js | tap-spec"
|
||||
},
|
||||
"version": "1.3.1"
|
||||
}
|
16
node_modules/klaw/src/assign.js
generated
vendored
Normal file
16
node_modules/klaw/src/assign.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// simple mutable assign (extracted from fs-extra)
|
||||
// I really like object-assign package, but I wanted a lean package with zero deps
|
||||
function _assign () {
|
||||
var args = [].slice.call(arguments).filter(function (i) { return i })
|
||||
var dest = args.shift()
|
||||
args.forEach(function (src) {
|
||||
Object.keys(src).forEach(function (key) {
|
||||
dest[key] = src[key]
|
||||
})
|
||||
})
|
||||
|
||||
return dest
|
||||
}
|
||||
|
||||
// thank you baby Jesus for Node v4 and Object.assign
|
||||
module.exports = Object.assign || _assign
|
57
node_modules/klaw/src/index.js
generated
vendored
Normal file
57
node_modules/klaw/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
var assert = require('assert')
|
||||
var fs
|
||||
try {
|
||||
fs = require('graceful-fs')
|
||||
} catch (e) {
|
||||
fs = require('fs')
|
||||
}
|
||||
var path = require('path')
|
||||
var Readable = require('stream').Readable
|
||||
var util = require('util')
|
||||
var assign = require('./assign')
|
||||
|
||||
function Walker (dir, options) {
|
||||
assert.strictEqual(typeof dir, 'string', '`dir` parameter should be of type string. Got type: ' + typeof dir)
|
||||
var defaultStreamOptions = { objectMode: true }
|
||||
var defaultOpts = { queueMethod: 'shift', pathSorter: undefined, filter: undefined }
|
||||
options = assign(defaultOpts, options, defaultStreamOptions)
|
||||
|
||||
Readable.call(this, options)
|
||||
this.root = path.resolve(dir)
|
||||
this.paths = [this.root]
|
||||
this.options = options
|
||||
this.fs = options.fs || fs // mock-fs
|
||||
}
|
||||
util.inherits(Walker, Readable)
|
||||
|
||||
Walker.prototype._read = function () {
|
||||
if (this.paths.length === 0) return this.push(null)
|
||||
var self = this
|
||||
var pathItem = this.paths[this.options.queueMethod]()
|
||||
|
||||
self.fs.lstat(pathItem, function (err, stats) {
|
||||
var item = { path: pathItem, stats: stats }
|
||||
if (err) return self.emit('error', err, item)
|
||||
if (!stats.isDirectory()) return self.push(item)
|
||||
|
||||
self.fs.readdir(pathItem, function (err, pathItems) {
|
||||
if (err) {
|
||||
self.push(item)
|
||||
return self.emit('error', err, item)
|
||||
}
|
||||
|
||||
pathItems = pathItems.map(function (part) { return path.join(pathItem, part) })
|
||||
if (self.options.filter) pathItems = pathItems.filter(self.options.filter)
|
||||
if (self.options.pathSorter) pathItems.sort(self.options.pathSorter)
|
||||
pathItems.forEach(function (pi) { self.paths.push(pi) })
|
||||
|
||||
self.push(item)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function walk (root, options) {
|
||||
return new Walker(root, options)
|
||||
}
|
||||
|
||||
module.exports = walk
|
Reference in New Issue
Block a user