08-27-周三_17-09-29

This commit is contained in:
2025-08-27 17:10:05 +08:00
commit 86df397d8f
12735 changed files with 1145479 additions and 0 deletions

8
node_modules/fs-extra/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
.nyc_output/
coverage/
test/
.travis.yml
appveyor.yml
lib/**/__tests__/
test/readme.md
test.js

726
node_modules/fs-extra/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,726 @@
0.26.7 / 2016-03-16
-------------------
- fixed `copy()` if source and dest are the same. [#230][#230]
0.26.6 / 2016-03-15
-------------------
- fixed if `emptyDir()` does not have a callback: [#229][#229]
0.26.5 / 2016-01-27
-------------------
- `copy()` with two arguments (w/o callback) was broken. See: [#215][#215]
0.26.4 / 2016-01-05
-------------------
- `copySync()` made `preserveTimestamps` default consistent with `copy()` which is `false`. See: [#208][#208]
0.26.3 / 2015-12-17
-------------------
- fixed `copy()` hangup in copying blockDevice / characterDevice / `/dev/null`. See: [#193][#193]
0.26.2 / 2015-11-02
-------------------
- fixed `outputJson{Sync}()` spacing adherence to `fs.spaces`
0.26.1 / 2015-11-02
-------------------
- fixed `copySync()` when `clogger=true` and the destination is read only. See: [#190][#190]
0.26.0 / 2015-10-25
-------------------
- extracted the `walk()` function into its own module [`klaw`](https://github.com/jprichardson/node-klaw).
0.25.0 / 2015-10-24
-------------------
- now has a file walker `walk()`
0.24.0 / 2015-08-28
-------------------
- removed alias `delete()` and `deleteSync()`. See: [#171][#171]
0.23.1 / 2015-08-07
-------------------
- Better handling of errors for `move()` when moving across devices. [#170][#170]
- `ensureSymlink()` and `ensureLink()` should not throw errors if link exists. [#169][#169]
0.23.0 / 2015-08-06
-------------------
- added `ensureLink{Sync}()` and `ensureSymlink{Sync}()`. See: [#165][#165]
0.22.1 / 2015-07-09
-------------------
- Prevent calling `hasMillisResSync()` on module load. See: [#149][#149].
Fixes regression that was introduced in `0.21.0`.
0.22.0 / 2015-07-09
-------------------
- preserve permissions / ownership in `copy()`. See: [#54][#54]
0.21.0 / 2015-07-04
-------------------
- add option to preserve timestamps in `copy()` and `copySync()`. See: [#141][#141]
- updated `graceful-fs@3.x` to `4.x`. This brings in features from `amazing-graceful-fs` (much cleaner code / less hacks)
0.20.1 / 2015-06-23
-------------------
- fixed regression caused by latest jsonfile update: See: https://github.com/jprichardson/node-jsonfile/issues/26
0.20.0 / 2015-06-19
-------------------
- removed `jsonfile` aliases with `File` in the name, they weren't documented and probably weren't in use e.g.
this package had both `fs.readJsonFile` and `fs.readJson` that were aliases to each other, now use `fs.readJson`.
- preliminary walker created. Intentionally not documented. If you use it, it will almost certainly change and break your code.
- started moving tests inline
- upgraded to `jsonfile@2.1.0`, can now pass JSON revivers/replacers to `readJson()`, `writeJson()`, `outputJson()`
0.19.0 / 2015-06-08
-------------------
- `fs.copy()` had support for Node v0.8, dropped support
0.18.4 / 2015-05-22
-------------------
- fixed license field according to this: [#136][#136] and https://github.com/npm/npm/releases/tag/v2.10.0
0.18.3 / 2015-05-08
-------------------
- bugfix: handle `EEXIST` when clobbering on some Linux systems. [#134][#134]
0.18.2 / 2015-04-17
-------------------
- bugfix: allow `F_OK` ([#120][#120])
0.18.1 / 2015-04-15
-------------------
- improved windows support for `move()` a bit. https://github.com/jprichardson/node-fs-extra/commit/92838980f25dc2ee4ec46b43ee14d3c4a1d30c1b
- fixed a lot of tests for Windows (appveyor)
0.18.0 / 2015-03-31
-------------------
- added `emptyDir()` and `emptyDirSync()`
0.17.0 / 2015-03-28
-------------------
- `copySync` added `clobber` option (before always would clobber, now if `clobber` is `false` it throws an error if the destination exists).
**Only works with files at the moment.**
- `createOutputStream()` added. See: [#118][#118]
0.16.5 / 2015-03-08
-------------------
- fixed `fs.move` when `clobber` is `true` and destination is a directory, it should clobber. [#114][#114]
0.16.4 / 2015-03-01
-------------------
- `fs.mkdirs` fix infinite loop on Windows. See: See https://github.com/substack/node-mkdirp/pull/74 and https://github.com/substack/node-mkdirp/issues/66
0.16.3 / 2015-01-28
-------------------
- reverted https://github.com/jprichardson/node-fs-extra/commit/1ee77c8a805eba5b99382a2591ff99667847c9c9
0.16.2 / 2015-01-28
-------------------
- fixed `fs.copy` for Node v0.8 (support is temporary and will be removed in the near future)
0.16.1 / 2015-01-28
-------------------
- if `setImmediate` is not available, fall back to `process.nextTick`
0.16.0 / 2015-01-28
-------------------
- bugfix `fs.move()` into itself. Closes #104
- bugfix `fs.move()` moving directory across device. Closes #108
- added coveralls support
- bugfix: nasty multiple callback `fs.copy()` bug. Closes #98
- misc fs.copy code cleanups
0.15.0 / 2015-01-21
-------------------
- dropped `ncp`, imported code in
- because of previous, now supports `io.js`
- `graceful-fs` is now a dependency
0.14.0 / 2015-01-05
-------------------
- changed `copy`/`copySync` from `fs.copy(src, dest, [filters], callback)` to `fs.copy(src, dest, [options], callback)` [#100][#100]
- removed mockfs tests for mkdirp (this may be temporary, but was getting in the way of other tests)
0.13.0 / 2014-12-10
-------------------
- removed `touch` and `touchSync` methods (they didn't handle permissions like UNIX touch)
- updated `"ncp": "^0.6.0"` to `"ncp": "^1.0.1"`
- imported `mkdirp` => `minimist` and `mkdirp` are no longer dependences, should now appease people who wanted `mkdirp` to be `--use_strict` safe. See [#59]([#59][#59])
0.12.0 / 2014-09-22
-------------------
- copy symlinks in `copySync()` [#85][#85]
0.11.1 / 2014-09-02
-------------------
- bugfix `copySync()` preserve file permissions [#80][#80]
0.11.0 / 2014-08-11
-------------------
- upgraded `"ncp": "^0.5.1"` to `"ncp": "^0.6.0"`
- upgrade `jsonfile": "^1.2.0"` to `jsonfile": "^2.0.0"` => on write, json files now have `\n` at end. Also adds `options.throws` to `readJsonSync()`
see https://github.com/jprichardson/node-jsonfile#readfilesyncfilename-options for more details.
0.10.0 / 2014-06-29
------------------
* bugfix: upgaded `"jsonfile": "~1.1.0"` to `"jsonfile": "^1.2.0"`, bumped minor because of `jsonfile` dep change
from `~` to `^`. #67
0.9.1 / 2014-05-22
------------------
* removed Node.js `0.8.x` support, `0.9.0` was published moments ago and should have been done there
0.9.0 / 2014-05-22
------------------
* upgraded `ncp` from `~0.4.2` to `^0.5.1`, #58
* upgraded `rimraf` from `~2.2.6` to `^2.2.8`
* upgraded `mkdirp` from `0.3.x` to `^0.5.0`
* added methods `ensureFile()`, `ensureFileSync()`
* added methods `ensureDir()`, `ensureDirSync()` #31
* added `move()` method. From: https://github.com/andrewrk/node-mv
0.8.1 / 2013-10-24
------------------
* copy failed to return an error to the callback if a file doesn't exist (ulikoehler #38, #39)
0.8.0 / 2013-10-14
------------------
* `filter` implemented on `copy()` and `copySync()`. (Srirangan / #36)
0.7.1 / 2013-10-12
------------------
* `copySync()` implemented (Srirangan / #33)
* updated to the latest `jsonfile` version `1.1.0` which gives `options` params for the JSON methods. Closes #32
0.7.0 / 2013-10-07
------------------
* update readme conventions
* `copy()` now works if destination directory does not exist. Closes #29
0.6.4 / 2013-09-05
------------------
* changed `homepage` field in package.json to remove NPM warning
0.6.3 / 2013-06-28
------------------
* changed JSON spacing default from `4` to `2` to follow Node conventions
* updated `jsonfile` dep
* updated `rimraf` dep
0.6.2 / 2013-06-28
------------------
* added .npmignore, #25
0.6.1 / 2013-05-14
------------------
* modified for `strict` mode, closes #24
* added `outputJson()/outputJsonSync()`, closes #23
0.6.0 / 2013-03-18
------------------
* removed node 0.6 support
* added node 0.10 support
* upgraded to latest `ncp` and `rimraf`.
* optional `graceful-fs` support. Closes #17
0.5.0 / 2013-02-03
------------------
* Removed `readTextFile`.
* Renamed `readJSONFile` to `readJSON` and `readJson`, same with write.
* Restructured documentation a bit. Added roadmap.
0.4.0 / 2013-01-28
------------------
* Set default spaces in `jsonfile` from 4 to 2.
* Updated `testutil` deps for tests.
* Renamed `touch()` to `createFile()`
* Added `outputFile()` and `outputFileSync()`
* Changed creation of testing diretories so the /tmp dir is not littered.
* Added `readTextFile()` and `readTextFileSync()`.
0.3.2 / 2012-11-01
------------------
* Added `touch()` and `touchSync()` methods.
0.3.1 / 2012-10-11
------------------
* Fixed some stray globals.
0.3.0 / 2012-10-09
------------------
* Removed all CoffeeScript from tests.
* Renamed `mkdir` to `mkdirs`/`mkdirp`.
0.2.1 / 2012-09-11
------------------
* Updated `rimraf` dep.
0.2.0 / 2012-09-10
------------------
* Rewrote module into JavaScript. (Must still rewrite tests into JavaScript)
* Added all methods of [jsonfile][https://github.com/jprichardson/node-jsonfile]
* Added Travis-CI.
0.1.3 / 2012-08-13
------------------
* Added method `readJSONFile`.
0.1.2 / 2012-06-15
------------------
* Bug fix: `deleteSync()` didn't exist.
* Verified Node v0.8 compatibility.
0.1.1 / 2012-06-15
------------------
* Fixed bug in `remove()`/`delete()` that wouldn't execute the function if a callback wasn't passed.
0.1.0 / 2012-05-31
------------------
* Renamed `copyFile()` to `copy()`. `copy()` can now copy directories (recursively) too.
* Renamed `rmrf()` to `remove()`.
* `remove()` aliased with `delete()`.
* Added `mkdirp` capabilities. Named: `mkdir()`. Hides Node.js native `mkdir()`.
* Instead of exporting the native `fs` module with new functions, I now copy over the native methods to a new object and export that instead.
0.0.4 / 2012-03-14
------------------
* Removed CoffeeScript dependency
0.0.3 / 2012-01-11
------------------
* Added methods rmrf and rmrfSync
* Moved tests from Jasmine to Mocha
<!--- fse.copy throws error when only src and dest provided [bug, documentation, feature-copy] -->
[#215]: https://github.com/jprichardson/node-fs-extra/pull/215
<!--- Fixing copySync anchor tag -->
[#214]: https://github.com/jprichardson/node-fs-extra/pull/214
<!--- Merge extfs with this repo -->
[#213]: https://github.com/jprichardson/node-fs-extra/issues/213
<!--- Update year to 2016 in README.md and LICENSE -->
[#212]: https://github.com/jprichardson/node-fs-extra/pull/212
<!--- Not copying all files -->
[#211]: https://github.com/jprichardson/node-fs-extra/issues/211
<!--- copy/copySync behave differently when copying a symbolic file [bug, documentation, feature-copy] -->
[#210]: https://github.com/jprichardson/node-fs-extra/issues/210
<!--- In Windows invalid directory name causes infinite loop in ensureDir(). [bug] -->
[#209]: https://github.com/jprichardson/node-fs-extra/issues/209
<!--- fix options.preserveTimestamps to false in copy-sync by default [feature-copy] -->
[#208]: https://github.com/jprichardson/node-fs-extra/pull/208
<!--- Add `compare` suite of functions -->
[#207]: https://github.com/jprichardson/node-fs-extra/issues/207
<!--- outputFileSync -->
[#206]: https://github.com/jprichardson/node-fs-extra/issues/206
<!--- fix documents about copy/copySync [documentation, feature-copy] -->
[#205]: https://github.com/jprichardson/node-fs-extra/issues/205
<!--- allow copy of block and character device files -->
[#204]: https://github.com/jprichardson/node-fs-extra/pull/204
<!--- copy method's argument options couldn't be undefined [bug, feature-copy] -->
[#203]: https://github.com/jprichardson/node-fs-extra/issues/203
<!--- why there is not a walkSync method? -->
[#202]: https://github.com/jprichardson/node-fs-extra/issues/202
<!--- clobber for directories [feature-copy, future] -->
[#201]: https://github.com/jprichardson/node-fs-extra/issues/201
<!--- 'copySync' doesn't work in sync -->
[#200]: https://github.com/jprichardson/node-fs-extra/issues/200
<!--- fs.copySync fails if user does not own file [bug, feature-copy] -->
[#199]: https://github.com/jprichardson/node-fs-extra/issues/199
<!--- handle copying between identical files [feature-copy] -->
[#198]: https://github.com/jprichardson/node-fs-extra/issues/198
<!--- Missing documentation for `outputFile` `options` 3rd parameter [documentation] -->
[#197]: https://github.com/jprichardson/node-fs-extra/issues/197
<!--- copy filter: async function and/or function called with `fs.stat` result [future] -->
[#196]: https://github.com/jprichardson/node-fs-extra/issues/196
<!--- How to override with outputFile? -->
[#195]: https://github.com/jprichardson/node-fs-extra/issues/195
<!--- allow ensureFile(Sync) to provide data to be written to created file -->
[#194]: https://github.com/jprichardson/node-fs-extra/pull/194
<!--- `fs.copy` fails silently if source file is /dev/null [bug, feature-copy] -->
[#193]: https://github.com/jprichardson/node-fs-extra/issues/193
<!--- Remove fs.createOutputStream() -->
[#192]: https://github.com/jprichardson/node-fs-extra/issues/192
<!--- How to copy symlinks to target as normal folders [feature-copy] -->
[#191]: https://github.com/jprichardson/node-fs-extra/issues/191
<!--- copySync to overwrite destination file if readonly and clobber true -->
[#190]: https://github.com/jprichardson/node-fs-extra/pull/190
<!--- move.test fix to support CRLF on Windows -->
[#189]: https://github.com/jprichardson/node-fs-extra/pull/189
<!--- move.test failing on windows platform -->
[#188]: https://github.com/jprichardson/node-fs-extra/issues/188
<!--- Not filter each file, stops on first false -->
[#187]: https://github.com/jprichardson/node-fs-extra/issues/187
<!--- Do you need a .size() function in this module? [future] -->
[#186]: https://github.com/jprichardson/node-fs-extra/issues/186
<!--- Doesn't work on NodeJS v4.x -->
[#185]: https://github.com/jprichardson/node-fs-extra/issues/185
<!--- CLI equivalent for fs-extra -->
[#184]: https://github.com/jprichardson/node-fs-extra/issues/184
<!--- with clobber true, copy and copySync behave differently if destination file is read only [bug, feature-copy] -->
[#183]: https://github.com/jprichardson/node-fs-extra/issues/183
<!--- ensureDir(dir, callback) second callback parameter not specified -->
[#182]: https://github.com/jprichardson/node-fs-extra/issues/182
<!--- Add ability to remove file securely [enhancement, wont-fix] -->
[#181]: https://github.com/jprichardson/node-fs-extra/issues/181
<!--- Filter option doesn't work the same way in copy and copySync [bug, feature-copy] -->
[#180]: https://github.com/jprichardson/node-fs-extra/issues/180
<!--- Include opendir -->
[#179]: https://github.com/jprichardson/node-fs-extra/issues/179
<!--- ENOTEMPTY is thrown on removeSync -->
[#178]: https://github.com/jprichardson/node-fs-extra/issues/178
<!--- fix `remove()` wildcards (introduced by rimraf) [feature-remove] -->
[#177]: https://github.com/jprichardson/node-fs-extra/issues/177
<!--- createOutputStream doesn't emit 'end' event -->
[#176]: https://github.com/jprichardson/node-fs-extra/issues/176
<!--- [Feature Request].moveSync support [feature-move, future] -->
[#175]: https://github.com/jprichardson/node-fs-extra/issues/175
<!--- Fix copy formatting and document options.filter -->
[#174]: https://github.com/jprichardson/node-fs-extra/pull/174
<!--- Feature Request: writeJson should mkdirs -->
[#173]: https://github.com/jprichardson/node-fs-extra/issues/173
<!--- rename `clobber` flags to `overwrite` -->
[#172]: https://github.com/jprichardson/node-fs-extra/issues/172
<!--- remove unnecessary aliases -->
[#171]: https://github.com/jprichardson/node-fs-extra/issues/171
<!--- More robust handling of errors moving across virtual drives -->
[#170]: https://github.com/jprichardson/node-fs-extra/pull/170
<!--- suppress ensureLink & ensureSymlink dest exists error -->
[#169]: https://github.com/jprichardson/node-fs-extra/pull/169
<!--- suppress ensurelink dest exists error -->
[#168]: https://github.com/jprichardson/node-fs-extra/pull/168
<!--- Adds basic (string, buffer) support for ensureFile content [future] -->
[#167]: https://github.com/jprichardson/node-fs-extra/pull/167
<!--- Adds basic (string, buffer) support for ensureFile content -->
[#166]: https://github.com/jprichardson/node-fs-extra/pull/166
<!--- ensure for link & symlink -->
[#165]: https://github.com/jprichardson/node-fs-extra/pull/165
<!--- Feature Request: ensureFile to take optional argument for file content -->
[#164]: https://github.com/jprichardson/node-fs-extra/issues/164
<!--- ouputJson not formatted out of the box [bug] -->
[#163]: https://github.com/jprichardson/node-fs-extra/issues/163
<!--- ensure symlink & link -->
[#162]: https://github.com/jprichardson/node-fs-extra/pull/162
<!--- ensure symlink & link -->
[#161]: https://github.com/jprichardson/node-fs-extra/pull/161
<!--- ensure symlink & link -->
[#160]: https://github.com/jprichardson/node-fs-extra/pull/160
<!--- ensure symlink & link -->
[#159]: https://github.com/jprichardson/node-fs-extra/pull/159
<!--- Feature Request: ensureLink and ensureSymlink methods -->
[#158]: https://github.com/jprichardson/node-fs-extra/issues/158
<!--- writeJson isn't formatted -->
[#157]: https://github.com/jprichardson/node-fs-extra/issues/157
<!--- Promise.promisifyAll doesn't work for some methods -->
[#156]: https://github.com/jprichardson/node-fs-extra/issues/156
<!--- Readme -->
[#155]: https://github.com/jprichardson/node-fs-extra/issues/155
<!--- /tmp/millis-test-sync -->
[#154]: https://github.com/jprichardson/node-fs-extra/issues/154
<!--- Make preserveTimes also work on read-only files. Closes #152 -->
[#153]: https://github.com/jprichardson/node-fs-extra/pull/153
<!--- fs.copy fails for read-only files with preserveTimestamp=true [feature-copy] -->
[#152]: https://github.com/jprichardson/node-fs-extra/issues/152
<!--- TOC does not work correctly on npm [documentation] -->
[#151]: https://github.com/jprichardson/node-fs-extra/issues/151
<!--- Remove test file fixtures, create with code. -->
[#150]: https://github.com/jprichardson/node-fs-extra/issues/150
<!--- /tmp/millis-test-sync -->
[#149]: https://github.com/jprichardson/node-fs-extra/issues/149
<!--- split out `Sync` methods in documentation -->
[#148]: https://github.com/jprichardson/node-fs-extra/issues/148
<!--- Adding rmdirIfEmpty -->
[#147]: https://github.com/jprichardson/node-fs-extra/issues/147
<!--- ensure test.js works -->
[#146]: https://github.com/jprichardson/node-fs-extra/pull/146
<!--- Add `fs.exists` and `fs.existsSync` if it doesn't exist. -->
[#145]: https://github.com/jprichardson/node-fs-extra/issues/145
<!--- tests failing -->
[#144]: https://github.com/jprichardson/node-fs-extra/issues/144
<!--- update graceful-fs -->
[#143]: https://github.com/jprichardson/node-fs-extra/issues/143
<!--- PrependFile Feature -->
[#142]: https://github.com/jprichardson/node-fs-extra/issues/142
<!--- Add option to preserve timestamps -->
[#141]: https://github.com/jprichardson/node-fs-extra/pull/141
<!--- Json file reading fails with 'utf8' -->
[#140]: https://github.com/jprichardson/node-fs-extra/issues/140
<!--- Preserve file timestamp on copy. Closes #138 -->
[#139]: https://github.com/jprichardson/node-fs-extra/pull/139
<!--- Preserve timestamps on copying files -->
[#138]: https://github.com/jprichardson/node-fs-extra/issues/138
<!--- outputFile/outputJson: Unexpected end of input -->
[#137]: https://github.com/jprichardson/node-fs-extra/issues/137
<!--- Update license attribute -->
[#136]: https://github.com/jprichardson/node-fs-extra/pull/136
<!--- emptyDir throws Error if no callback is provided -->
[#135]: https://github.com/jprichardson/node-fs-extra/issues/135
<!--- Handle EEXIST error when clobbering dir -->
[#134]: https://github.com/jprichardson/node-fs-extra/pull/134
<!--- Travis runs with `sudo: false` -->
[#133]: https://github.com/jprichardson/node-fs-extra/pull/133
<!--- isDirectory method -->
[#132]: https://github.com/jprichardson/node-fs-extra/pull/132
<!--- copySync is not working iojs 1.8.4 on linux [feature-copy] -->
[#131]: https://github.com/jprichardson/node-fs-extra/issues/131
<!--- Please review additional features. -->
[#130]: https://github.com/jprichardson/node-fs-extra/pull/130
<!--- can you review this feature? -->
[#129]: https://github.com/jprichardson/node-fs-extra/pull/129
<!--- fsExtra.move(filepath, newPath) broken; -->
[#128]: https://github.com/jprichardson/node-fs-extra/issues/128
<!--- consider using fs.access to remove deprecated warnings for fs.exists -->
[#127]: https://github.com/jprichardson/node-fs-extra/issues/127
<!--- TypeError: Object #<Object> has no method 'access' -->
[#126]: https://github.com/jprichardson/node-fs-extra/issues/126
<!--- Question: What do the *Sync function do different from non-sync -->
[#125]: https://github.com/jprichardson/node-fs-extra/issues/125
<!--- move with clobber option 'ENOTEMPTY' -->
[#124]: https://github.com/jprichardson/node-fs-extra/issues/124
<!--- Only copy the content of a directory -->
[#123]: https://github.com/jprichardson/node-fs-extra/issues/123
<!--- Update section links in README to match current section ids. -->
[#122]: https://github.com/jprichardson/node-fs-extra/pull/122
<!--- emptyDir is undefined -->
[#121]: https://github.com/jprichardson/node-fs-extra/issues/121
<!--- usage bug caused by shallow cloning methods of 'graceful-fs' -->
[#120]: https://github.com/jprichardson/node-fs-extra/issues/120
<!--- mkdirs and ensureDir never invoke callback and consume CPU indefinitely if provided a path with invalid characters on Windows -->
[#119]: https://github.com/jprichardson/node-fs-extra/issues/119
<!--- createOutputStream -->
[#118]: https://github.com/jprichardson/node-fs-extra/pull/118
<!--- Fixed issue with slash separated paths on windows -->
[#117]: https://github.com/jprichardson/node-fs-extra/pull/117
<!--- copySync can only copy directories not files [documentation, feature-copy] -->
[#116]: https://github.com/jprichardson/node-fs-extra/issues/116
<!--- .Copy & .CopySync [feature-copy] -->
[#115]: https://github.com/jprichardson/node-fs-extra/issues/115
<!--- Fails to move (rename) directory to non-empty directory even with clobber: true -->
[#114]: https://github.com/jprichardson/node-fs-extra/issues/114
<!--- fs.copy seems to callback early if the destination file already exists -->
[#113]: https://github.com/jprichardson/node-fs-extra/issues/113
<!--- Copying a file into an existing directory -->
[#112]: https://github.com/jprichardson/node-fs-extra/pull/112
<!--- Moving a file into an existing directory -->
[#111]: https://github.com/jprichardson/node-fs-extra/pull/111
<!--- Moving a file into an existing directory -->
[#110]: https://github.com/jprichardson/node-fs-extra/pull/110
<!--- fs.move across windows drives fails -->
[#109]: https://github.com/jprichardson/node-fs-extra/issues/109
<!--- fse.move directories across multiple devices doesn't work -->
[#108]: https://github.com/jprichardson/node-fs-extra/issues/108
<!--- Check if dest path is an existing dir and copy or move source in it -->
[#107]: https://github.com/jprichardson/node-fs-extra/pull/107
<!--- fse.copySync crashes while copying across devices D: [feature-copy] -->
[#106]: https://github.com/jprichardson/node-fs-extra/issues/106
<!--- fs.copy hangs on iojs -->
[#105]: https://github.com/jprichardson/node-fs-extra/issues/105
<!--- fse.move deletes folders [bug] -->
[#104]: https://github.com/jprichardson/node-fs-extra/issues/104
<!--- Error: EMFILE with copy -->
[#103]: https://github.com/jprichardson/node-fs-extra/issues/103
<!--- touch / touchSync was removed ? -->
[#102]: https://github.com/jprichardson/node-fs-extra/issues/102
<!--- fs-extra promisified -->
[#101]: https://github.com/jprichardson/node-fs-extra/issues/101
<!--- copy: options object or filter to pass to ncp -->
[#100]: https://github.com/jprichardson/node-fs-extra/pull/100
<!--- ensureDir() modes [future] -->
[#99]: https://github.com/jprichardson/node-fs-extra/issues/99
<!--- fs.copy() incorrect async behavior [bug] -->
[#98]: https://github.com/jprichardson/node-fs-extra/issues/98
<!--- use path.join; fix copySync bug -->
[#97]: https://github.com/jprichardson/node-fs-extra/pull/97
<!--- destFolderExists in copySync is always undefined. -->
[#96]: https://github.com/jprichardson/node-fs-extra/issues/96
<!--- Using graceful-ncp instead of ncp -->
[#95]: https://github.com/jprichardson/node-fs-extra/pull/95
<!--- Error: EEXIST, file already exists '../mkdirp/bin/cmd.js' on fs.copySync() [enhancement, feature-copy] -->
[#94]: https://github.com/jprichardson/node-fs-extra/issues/94
<!--- Confusing error if drive not mounted [enhancement] -->
[#93]: https://github.com/jprichardson/node-fs-extra/issues/93
<!--- Problems with Bluebird -->
[#92]: https://github.com/jprichardson/node-fs-extra/issues/92
<!--- fs.copySync('/test', '/haha') is different with 'cp -r /test /haha' [enhancement] -->
[#91]: https://github.com/jprichardson/node-fs-extra/issues/91
<!--- Folder creation and file copy is Happening in 64 bit machine but not in 32 bit machine -->
[#90]: https://github.com/jprichardson/node-fs-extra/issues/90
<!--- Error: EEXIST using fs-extra's fs.copy to copy a directory on Windows -->
[#89]: https://github.com/jprichardson/node-fs-extra/issues/89
<!--- Stacking those libraries -->
[#88]: https://github.com/jprichardson/node-fs-extra/issues/88
<!--- createWriteStream + outputFile = ? -->
[#87]: https://github.com/jprichardson/node-fs-extra/issues/87
<!--- no moveSync? -->
[#86]: https://github.com/jprichardson/node-fs-extra/issues/86
<!--- Copy symlinks in copySync -->
[#85]: https://github.com/jprichardson/node-fs-extra/pull/85
<!--- Push latest version to npm ? -->
[#84]: https://github.com/jprichardson/node-fs-extra/issues/84
<!--- Prevent copying a directory into itself [feature-copy] -->
[#83]: https://github.com/jprichardson/node-fs-extra/issues/83
<!--- README updates for move -->
[#82]: https://github.com/jprichardson/node-fs-extra/pull/82
<!--- fd leak after fs.move -->
[#81]: https://github.com/jprichardson/node-fs-extra/issues/81
<!--- Preserve file mode in copySync -->
[#80]: https://github.com/jprichardson/node-fs-extra/pull/80
<!--- fs.copy only .html file empty -->
[#79]: https://github.com/jprichardson/node-fs-extra/issues/79
<!--- copySync was not applying filters to directories -->
[#78]: https://github.com/jprichardson/node-fs-extra/pull/78
<!--- Create README reference to bluebird -->
[#77]: https://github.com/jprichardson/node-fs-extra/issues/77
<!--- Create README reference to typescript -->
[#76]: https://github.com/jprichardson/node-fs-extra/issues/76
<!--- add glob as a dep? [question] -->
[#75]: https://github.com/jprichardson/node-fs-extra/issues/75
<!--- including new emptydir module -->
[#74]: https://github.com/jprichardson/node-fs-extra/pull/74
<!--- add dependency status in readme -->
[#73]: https://github.com/jprichardson/node-fs-extra/pull/73
<!--- Use svg instead of png to get better image quality -->
[#72]: https://github.com/jprichardson/node-fs-extra/pull/72
<!--- fse.copy not working on Windows 7 x64 OS, but, copySync does work -->
[#71]: https://github.com/jprichardson/node-fs-extra/issues/71
<!--- Not filter each file, stops on first false [bug] -->
[#70]: https://github.com/jprichardson/node-fs-extra/issues/70
<!--- How to check if folder exist and read the folder name -->
[#69]: https://github.com/jprichardson/node-fs-extra/issues/69
<!--- consider flag to readJsonSync (throw false) [enhancement] -->
[#68]: https://github.com/jprichardson/node-fs-extra/issues/68
<!--- docs for readJson incorrectly states that is accepts options -->
[#67]: https://github.com/jprichardson/node-fs-extra/issues/67
<!--- ENAMETOOLONG -->
[#66]: https://github.com/jprichardson/node-fs-extra/issues/66
<!--- exclude filter in fs.copy -->
[#65]: https://github.com/jprichardson/node-fs-extra/issues/65
<!--- Announce: mfs - monitor your fs-extra calls -->
[#64]: https://github.com/jprichardson/node-fs-extra/issues/64
<!--- Walk -->
[#63]: https://github.com/jprichardson/node-fs-extra/issues/63
<!--- npm install fs-extra doesn't work -->
[#62]: https://github.com/jprichardson/node-fs-extra/issues/62
<!--- No longer supports node 0.8 due to use of `^` in package.json dependencies -->
[#61]: https://github.com/jprichardson/node-fs-extra/issues/61
<!--- chmod & chown for mkdirs -->
[#60]: https://github.com/jprichardson/node-fs-extra/issues/60
<!--- Consider including mkdirp and making fs-extra "--use_strict" safe [question] -->
[#59]: https://github.com/jprichardson/node-fs-extra/issues/59
<!--- Stack trace not included in fs.copy error -->
[#58]: https://github.com/jprichardson/node-fs-extra/issues/58
<!--- Possible to include wildcards in delete? -->
[#57]: https://github.com/jprichardson/node-fs-extra/issues/57
<!--- Crash when have no access to write to destination file in copy -->
[#56]: https://github.com/jprichardson/node-fs-extra/issues/56
<!--- Is it possible to have any console output similar to Grunt copy module? -->
[#55]: https://github.com/jprichardson/node-fs-extra/issues/55
<!--- `copy` does not preserve file ownership and permissons -->
[#54]: https://github.com/jprichardson/node-fs-extra/issues/54
<!--- outputFile() - ability to write data in appending mode -->
[#53]: https://github.com/jprichardson/node-fs-extra/issues/53
<!--- This fixes (what I think) is a bug in copySync -->
[#52]: https://github.com/jprichardson/node-fs-extra/pull/52
<!--- Add a Bitdeli Badge to README -->
[#51]: https://github.com/jprichardson/node-fs-extra/pull/51
<!--- Replace mechanism in createFile -->
[#50]: https://github.com/jprichardson/node-fs-extra/issues/50
<!--- update rimraf to v2.2.6 -->
[#49]: https://github.com/jprichardson/node-fs-extra/pull/49
<!--- fs.copy issue [bug] -->
[#48]: https://github.com/jprichardson/node-fs-extra/issues/48
<!--- Bug in copy - callback called on readStream "close" - Fixed in ncp 0.5.0 -->
[#47]: https://github.com/jprichardson/node-fs-extra/issues/47
<!--- update copyright year -->
[#46]: https://github.com/jprichardson/node-fs-extra/pull/46
<!--- Added note about fse.outputFile() being the one that overwrites -->
[#45]: https://github.com/jprichardson/node-fs-extra/pull/45
<!--- Proposal: Stream support -->
[#44]: https://github.com/jprichardson/node-fs-extra/pull/44
<!--- Better error reporting -->
[#43]: https://github.com/jprichardson/node-fs-extra/issues/43
<!--- Performance issue? -->
[#42]: https://github.com/jprichardson/node-fs-extra/issues/42
<!--- There does seem to be a synchronous version now -->
[#41]: https://github.com/jprichardson/node-fs-extra/pull/41
<!--- fs.copy throw unexplained error ENOENT, utime -->
[#40]: https://github.com/jprichardson/node-fs-extra/issues/40
<!--- Added regression test for copy() return callback on error -->
[#39]: https://github.com/jprichardson/node-fs-extra/pull/39
<!--- Return err in copy() fstat cb, because stat could be undefined or null -->
[#38]: https://github.com/jprichardson/node-fs-extra/pull/38
<!--- Maybe include a line reader? [enhancement, question] -->
[#37]: https://github.com/jprichardson/node-fs-extra/issues/37
<!--- `filter` parameter `fs.copy` and `fs.copySync` -->
[#36]: https://github.com/jprichardson/node-fs-extra/pull/36
<!--- `filter` parameter `fs.copy` and `fs.copySync` -->
[#35]: https://github.com/jprichardson/node-fs-extra/pull/35
<!--- update docs to include options for JSON methods [enhancement] -->
[#34]: https://github.com/jprichardson/node-fs-extra/issues/34
<!--- fs_extra.copySync -->
[#33]: https://github.com/jprichardson/node-fs-extra/pull/33
<!--- update to latest jsonfile [enhancement] -->
[#32]: https://github.com/jprichardson/node-fs-extra/issues/32
<!--- Add ensure methods [enhancement] -->
[#31]: https://github.com/jprichardson/node-fs-extra/issues/31
<!--- update package.json optional dep `graceful-fs` -->
[#30]: https://github.com/jprichardson/node-fs-extra/issues/30
<!--- Copy failing if dest directory doesn't exist. Is this intended? -->
[#29]: https://github.com/jprichardson/node-fs-extra/issues/29
<!--- homepage field must be a string url. Deleted. -->
[#28]: https://github.com/jprichardson/node-fs-extra/issues/28
<!--- Update Readme -->
[#27]: https://github.com/jprichardson/node-fs-extra/issues/27
<!--- Add readdir recursive method. [enhancement] -->
[#26]: https://github.com/jprichardson/node-fs-extra/issues/26
<!--- adding an `.npmignore` file -->
[#25]: https://github.com/jprichardson/node-fs-extra/pull/25
<!--- [bug] cannot run in strict mode [bug] -->
[#24]: https://github.com/jprichardson/node-fs-extra/issues/24
<!--- `writeJSON()` should create parent directories -->
[#23]: https://github.com/jprichardson/node-fs-extra/issues/23
<!--- Add a limit option to mkdirs() -->
[#22]: https://github.com/jprichardson/node-fs-extra/pull/22
<!--- touch() in 0.10.0 -->
[#21]: https://github.com/jprichardson/node-fs-extra/issues/21
<!--- fs.remove yields callback before directory is really deleted -->
[#20]: https://github.com/jprichardson/node-fs-extra/issues/20
<!--- fs.copy err is empty array -->
[#19]: https://github.com/jprichardson/node-fs-extra/issues/19
<!--- Exposed copyFile Function -->
[#18]: https://github.com/jprichardson/node-fs-extra/pull/18
<!--- Use `require("graceful-fs")` if found instead of `require("fs")` -->
[#17]: https://github.com/jprichardson/node-fs-extra/issues/17
<!--- Update README.md -->
[#16]: https://github.com/jprichardson/node-fs-extra/pull/16
<!--- Implement cp -r but sync aka copySync. [enhancement] -->
[#15]: https://github.com/jprichardson/node-fs-extra/issues/15
<!--- fs.mkdirSync is broken in 0.3.1 -->
[#14]: https://github.com/jprichardson/node-fs-extra/issues/14
<!--- Thoughts on including a directory tree / file watcher? [enhancement, question] -->
[#13]: https://github.com/jprichardson/node-fs-extra/issues/13
<!--- copyFile & copyFileSync are global -->
[#12]: https://github.com/jprichardson/node-fs-extra/issues/12
<!--- Thoughts on including a file walker? [enhancement, question] -->
[#11]: https://github.com/jprichardson/node-fs-extra/issues/11
<!--- move / moveFile API [enhancement] -->
[#10]: https://github.com/jprichardson/node-fs-extra/issues/10
<!--- don't import normal fs stuff into fs-extra -->
[#9]: https://github.com/jprichardson/node-fs-extra/issues/9
<!--- Update rimraf to latest version -->
[#8]: https://github.com/jprichardson/node-fs-extra/pull/8
<!--- Remove CoffeeScript development dependency -->
[#6]: https://github.com/jprichardson/node-fs-extra/issues/6
<!--- comments on naming -->
[#5]: https://github.com/jprichardson/node-fs-extra/issues/5
<!--- version bump to 0.2 -->
[#4]: https://github.com/jprichardson/node-fs-extra/issues/4
<!--- Hi! I fixed some code for you! -->
[#3]: https://github.com/jprichardson/node-fs-extra/pull/3
<!--- Merge with fs.extra and mkdirp -->
[#2]: https://github.com/jprichardson/node-fs-extra/issues/2
<!--- file-extra npm !exist -->
[#1]: https://github.com/jprichardson/node-fs-extra/issues/1

15
node_modules/fs-extra/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
(The MIT License)
Copyright (c) 2011-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.

586
node_modules/fs-extra/README.md generated vendored Normal file
View File

@@ -0,0 +1,586 @@
Node.js: fs-extra
=================
[![build status](https://api.travis-ci.org/jprichardson/node-fs-extra.svg)](http://travis-ci.org/jprichardson/node-fs-extra)
[![windows Build status](https://img.shields.io/appveyor/ci/jprichardson/node-fs-extra/master.svg?label=windows%20build)](https://ci.appveyor.com/project/jprichardson/node-fs-extra/branch/master)
[![downloads per month](http://img.shields.io/npm/dm/fs-extra.svg)](https://www.npmjs.org/package/fs-extra)
[![Coverage Status](https://img.shields.io/coveralls/jprichardson/node-fs-extra.svg)](https://coveralls.io/r/jprichardson/node-fs-extra)
`fs-extra` adds file system methods that aren't included in the native `fs` module. It is a drop in replacement for `fs`.
**NOTE (2016-01-13):** Node v0.10 will be unsupported AFTER Ubuntu LTS releases their next version AND [Amazon Lambda
upgrades](http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html) its Node.js runtime from v0.10.
I anticipate this will happen around late spring / summer 2016. Please prepare accordingly. After this, we'll make a strong push
for a 1.0.0 release.
Why?
----
I got tired of including `mkdirp`, `rimraf`, and `cp -r` in most of my projects.
Installation
------------
npm install --save fs-extra
Usage
-----
`fs-extra` is a drop in replacement for native `fs`. All methods in `fs` are unmodified and attached to `fs-extra`.
You don't ever need to include the original `fs` module again:
```js
var fs = require('fs') // this is no longer necessary
```
you can now do this:
```js
var fs = require('fs-extra')
```
or if you prefer to make it clear that you're using `fs-extra` and not `fs`, you may want
to name your `fs` variable `fse` like so:
```js
var fse = require('fs-extra')
```
you can also keep both, but it's redundant:
```js
var fs = require('fs')
var fse = require('fs-extra')
```
Sync vs Async
-------------
Most methods are async by default (they take a callback with an `Error` as first argument).
Sync methods on the other hand will throw if an error occurs.
Example:
```js
var fs = require('fs-extra')
fs.copy('/tmp/myfile', '/tmp/mynewfile', function (err) {
if (err) return console.error(err)
console.log("success!")
});
try {
fs.copySync('/tmp/myfile', '/tmp/mynewfile')
console.log("success!")
} catch (err) {
console.error(err)
}
```
Methods
-------
- [copy](#copy)
- [copySync](#copy)
- [createOutputStream](#createoutputstreamfile-options)
- [emptyDir](#emptydirdir-callback)
- [emptyDirSync](#emptydirdir-callback)
- [ensureFile](#ensurefilefile-callback)
- [ensureFileSync](#ensurefilefile-callback)
- [ensureDir](#ensuredirdir-callback)
- [ensureDirSync](#ensuredirdir-callback)
- [ensureLink](#ensurelinksrcpath-dstpath-callback)
- [ensureLinkSync](#ensurelinksrcpath-dstpath-callback)
- [ensureSymlink](#ensuresymlinksrcpath-dstpath-type-callback)
- [ensureSymlinkSync](#ensuresymlinksrcpath-dstpath-type-callback)
- [mkdirs](#mkdirsdir-callback)
- [mkdirsSync](#mkdirsdir-callback)
- [move](#movesrc-dest-options-callback)
- [outputFile](#outputfilefile-data-options-callback)
- [outputFileSync](#outputfilefile-data-options-callback)
- [outputJson](#outputjsonfile-data-options-callback)
- [outputJsonSync](#outputjsonfile-data-options-callback)
- [readJson](#readjsonfile-options-callback)
- [readJsonSync](#readjsonfile-options-callback)
- [remove](#removedir-callback)
- [removeSync](#removedir-callback)
- [walk](#walk)
- [writeJson](#writejsonfile-object-options-callback)
- [writeJsonSync](#writejsonfile-object-options-callback)
**NOTE:** You can still use the native Node.js methods. They are copied over to `fs-extra`.
### copy()
**copy(src, dest, [options], callback)**
Copy a file or directory. The directory can have contents. Like `cp -r`.
Options:
- clobber (boolean): overwrite existing file or directory
- preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is `false`.
- filter: Function or RegExp to filter copied files. If function, return true to include, false to exclude. If RegExp, same as function, where `filter` is `filter.test`.
Sync: `copySync()`
Example:
```js
var fs = require('fs-extra')
fs.copy('/tmp/myfile', '/tmp/mynewfile', function (err) {
if (err) return console.error(err)
console.log("success!")
}) // copies file
fs.copy('/tmp/mydir', '/tmp/mynewdir', function (err) {
if (err) return console.error(err)
console.log('success!')
}) // copies directory, even if it has subdirectories or files
```
### createOutputStream(file, [options])
Exactly like `createWriteStream`, but if the directory does not exist, it's created.
Examples:
```js
var fs = require('fs-extra')
// if /tmp/some does not exist, it is created
var ws = fs.createOutputStream('/tmp/some/file.txt')
ws.write('hello\n')
```
Note on naming: you'll notice that fs-extra has some methods like `fs.outputJson`, `fs.outputFile`, etc that use the
word `output` to denote that if the containing directory does not exist, it should be created. If you can think of a
better succinct nomenclature for these methods, please open an issue for discussion. Thanks.
### emptyDir(dir, [callback])
Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted.
Alias: `emptydir()`
Sync: `emptyDirSync()`, `emptydirSync()`
Example:
```js
var fs = require('fs-extra')
// assume this directory has a lot of files and folders
fs.emptyDir('/tmp/some/dir', function (err) {
if (!err) console.log('success!')
})
```
### ensureFile(file, callback)
Ensures that the file exists. If the file that is requested to be created is in directories that do not exist, these directories are created. If the file already exists, it is **NOT MODIFIED**.
Alias: `createFile()`
Sync: `createFileSync()`,`ensureFileSync()`
Example:
```js
var fs = require('fs-extra')
var file = '/tmp/this/path/does/not/exist/file.txt'
fs.ensureFile(file, function (err) {
console.log(err) // => null
// file has now been created, including the directory it is to be placed in
})
```
### ensureDir(dir, callback)
Ensures that the directory exists. If the directory structure does not exist, it is created.
Sync: `ensureDirSync()`
Example:
```js
var fs = require('fs-extra')
var dir = '/tmp/this/path/does/not/exist'
fs.ensureDir(dir, function (err) {
console.log(err) // => null
// dir has now been created, including the directory it is to be placed in
})
```
### ensureLink(srcpath, dstpath, callback)
Ensures that the link exists. If the directory structure does not exist, it is created.
Sync: `ensureLinkSync()`
Example:
```js
var fs = require('fs-extra')
var srcpath = '/tmp/file.txt'
var dstpath = '/tmp/this/path/does/not/exist/file.txt'
fs.ensureLink(srcpath, dstpath, function (err) {
console.log(err) // => null
// link has now been created, including the directory it is to be placed in
})
```
### ensureSymlink(srcpath, dstpath, [type], callback)
Ensures that the symlink exists. If the directory structure does not exist, it is created.
Sync: `ensureSymlinkSync()`
Example:
```js
var fs = require('fs-extra')
var srcpath = '/tmp/file.txt'
var dstpath = '/tmp/this/path/does/not/exist/file.txt'
fs.ensureSymlink(srcpath, dstpath, function (err) {
console.log(err) // => null
// symlink has now been created, including the directory it is to be placed in
})
```
### mkdirs(dir, callback)
Creates a directory. If the parent hierarchy doesn't exist, it's created. Like `mkdir -p`.
Alias: `mkdirp()`
Sync: `mkdirsSync()` / `mkdirpSync()`
Examples:
```js
var fs = require('fs-extra')
fs.mkdirs('/tmp/some/long/path/that/prob/doesnt/exist', function (err) {
if (err) return console.error(err)
console.log("success!")
})
fs.mkdirsSync('/tmp/another/path')
```
### move(src, dest, [options], callback)
Moves a file or directory, even across devices.
Options:
- clobber (boolean): overwrite existing file or directory
- limit (number): number of concurrent moves, see ncp for more information
Example:
```js
var fs = require('fs-extra')
fs.move('/tmp/somefile', '/tmp/does/not/exist/yet/somefile', function (err) {
if (err) return console.error(err)
console.log("success!")
})
```
### outputFile(file, data, [options], callback)
Almost the same as `writeFile` (i.e. it [overwrites](http://pages.citebite.com/v2o5n8l2f5reb)), except that if the parent directory does not exist, it's created. `options` are what you'd pass to [`fs.writeFile()`](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback).
Sync: `outputFileSync()`
Example:
```js
var fs = require('fs-extra')
var file = '/tmp/this/path/does/not/exist/file.txt'
fs.outputFile(file, 'hello!', function (err) {
console.log(err) // => null
fs.readFile(file, 'utf8', function (err, data) {
console.log(data) // => hello!
})
})
```
### outputJson(file, data, [options], callback)
Almost the same as `writeJson`, except that if the directory does not exist, it's created.
`options` are what you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
Alias: `outputJSON()`
Sync: `outputJsonSync()`, `outputJSONSync()`
Example:
```js
var fs = require('fs-extra')
var file = '/tmp/this/path/does/not/exist/file.txt'
fs.outputJson(file, {name: 'JP'}, function (err) {
console.log(err) // => null
fs.readJson(file, function(err, data) {
console.log(data.name) // => JP
})
})
```
### readJson(file, [options], callback)
Reads a JSON file and then parses it into an object. `options` are the same
that you'd pass to [`jsonFile.readFile`](https://github.com/jprichardson/node-jsonfile#readfilefilename-options-callback).
Alias: `readJSON()`
Sync: `readJsonSync()`, `readJSONSync()`
Example:
```js
var fs = require('fs-extra')
fs.readJson('./package.json', function (err, packageObj) {
console.log(packageObj.version) // => 0.1.3
})
```
`readJsonSync()` can take a `throws` option set to `false` and it won't throw if the JSON is invalid. Example:
```js
var fs = require('fs-extra')
var file = path.join('/tmp/some-invalid.json')
var data = '{not valid JSON'
fs.writeFileSync(file, data)
var obj = fs.readJsonSync(file, {throws: false})
console.log(obj) // => null
```
### remove(dir, callback)
Removes a file or directory. The directory can have contents. Like `rm -rf`.
Sync: `removeSync()`
Examples:
```js
var fs = require('fs-extra')
fs.remove('/tmp/myfile', function (err) {
if (err) return console.error(err)
console.log('success!')
})
fs.removeSync('/home/jprichardson') //I just deleted my entire HOME directory.
```
### walk()
**walk(dir, [streamOptions])**
The function `walk()` from the module [`klaw`](https://github.com/jprichardson/node-klaw).
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).
Streams 1 (push) example:
```js
var items = [] // files, directories, symlinks, etc
fse.walk(TEST_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 items = [] // files, directories, symlinks, etc
fse.walk(TEST_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/.
**See [`klaw` documentation](https://github.com/jprichardson/node-klaw) for more detailed usage.**
### writeJson(file, object, [options], callback)
Writes an object to a JSON file. `options` are the same that
you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
Alias: `writeJSON()`
Sync: `writeJsonSync()`, `writeJSONSync()`
Example:
```js
var fs = require('fs-extra')
fs.writeJson('./package.json', {name: 'fs-extra'}, function (err) {
console.log(err)
})
```
Third Party
-----------
### Promises
Use [Bluebird](https://github.com/petkaantonov/bluebird). See https://github.com/petkaantonov/bluebird/blob/master/API.md#promisification. `fs-extra` is
explicitly listed as supported.
```js
var Promise = require('bluebird')
var fs = Promise.promisifyAll(require('fs-extra'))
```
Or you can use the package [`fs-extra-promise`](https://github.com/overlookmotel/fs-extra-promise) that marries the two together.
### TypeScript
If you like TypeScript, you can use `fs-extra` with it: https://github.com/borisyankov/DefinitelyTyped/tree/master/fs-extra
### File / Directory Watching
If you want to watch for changes to files or directories, then you should use [chokidar](https://github.com/paulmillr/chokidar).
### Misc.
- [mfs](https://github.com/cadorn/mfs) - Monitor your fs-extra calls.
Hacking on fs-extra
-------------------
Wanna hack on `fs-extra`? Great! Your help is needed! [fs-extra is one of the most depended upon Node.js packages](http://nodei.co/npm/fs-extra.png?downloads=true&downloadRank=true&stars=true). This project
uses [JavaScript Standard Style](https://github.com/feross/standard) - if the name or style choices bother you,
you're gonna have to get over it :) If `standard` is good enough for `npm`, it's good enough for `fs-extra`.
[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
What's needed?
- First, take a look at existing issues. Those are probably going to be where the priority lies.
- More tests for edge cases. Specifically on different platforms. There can never be enough tests.
- Really really help with the Windows tests. See appveyor outputs for more info.
- Improve test coverage. See coveralls output for more info.
- A directory walker. Probably this one: https://github.com/thlorenz/readdirp imported into `fs-extra`.
- After the directory walker is integrated, any function that needs to traverse directories like
`copy`, `remove`, or `mkdirs` should be built on top of it.
Note: If you make any big changes, **you should definitely post an issue for discussion first.**
Naming
------
I put a lot of thought into the naming of these functions. Inspired by @coolaj86's request. So he deserves much of the credit for raising the issue. See discussion(s) here:
* https://github.com/jprichardson/node-fs-extra/issues/2
* https://github.com/flatiron/utile/issues/11
* https://github.com/ryanmcgrath/wrench-js/issues/29
* https://github.com/substack/node-mkdirp/issues/17
First, I believe that in as many cases as possible, the [Node.js naming schemes](http://nodejs.org/api/fs.html) should be chosen. However, there are problems with the Node.js own naming schemes.
For example, `fs.readFile()` and `fs.readdir()`: the **F** is capitalized in *File* and the **d** is not capitalized in *dir*. Perhaps a bit pedantic, but they should still be consistent. Also, Node.js has chosen a lot of POSIX naming schemes, which I believe is great. See: `fs.mkdir()`, `fs.rmdir()`, `fs.chown()`, etc.
We have a dilemma though. How do you consistently name methods that perform the following POSIX commands: `cp`, `cp -r`, `mkdir -p`, and `rm -rf`?
My perspective: when in doubt, err on the side of simplicity. A directory is just a hierarchical grouping of directories and files. Consider that for a moment. So when you want to copy it or remove it, in most cases you'll want to copy or remove all of its contents. When you want to create a directory, if the directory that it's suppose to be contained in does not exist, then in most cases you'll want to create that too.
So, if you want to remove a file or a directory regardless of whether it has contents, just call `fs.remove(path)`. If you want to copy a file or a directory whether it has contents, just call `fs.copy(source, destination)`. If you want to create a directory regardless of whether its parent directories exist, just call `fs.mkdirs(path)` or `fs.mkdirp(path)`.
Credit
------
`fs-extra` wouldn't be possible without using the modules from the following authors:
- [Isaac Shlueter](https://github.com/isaacs)
- [Charlie McConnel](https://github.com/avianflu)
- [James Halliday](https://github.com/substack)
- [Andrew Kelley](https://github.com/andrewrk)
License
-------
Licensed under MIT
Copyright (c) 2011-2016 [JP Richardson](https://github.com/jprichardson)
[1]: http://nodejs.org/docs/latest/api/fs.html
[jsonfile]: https://github.com/jprichardson/node-jsonfile

39
node_modules/fs-extra/lib/copy-sync/copy-file-sync.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
var fs = require('graceful-fs')
var BUF_LENGTH = 64 * 1024
var _buff = new Buffer(BUF_LENGTH)
function copyFileSync (srcFile, destFile, options) {
var clobber = options.clobber
var preserveTimestamps = options.preserveTimestamps
if (fs.existsSync(destFile)) {
if (clobber) {
fs.chmodSync(destFile, parseInt('777', 8))
fs.unlinkSync(destFile)
} else {
throw Error('EEXIST')
}
}
var fdr = fs.openSync(srcFile, 'r')
var stat = fs.fstatSync(fdr)
var fdw = fs.openSync(destFile, 'w', stat.mode)
var bytesRead = 1
var pos = 0
while (bytesRead > 0) {
bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos)
fs.writeSync(fdw, _buff, 0, bytesRead)
pos += bytesRead
}
if (preserveTimestamps) {
fs.futimesSync(fdw, stat.atime, stat.mtime)
}
fs.closeSync(fdr)
fs.closeSync(fdw)
}
module.exports = copyFileSync

47
node_modules/fs-extra/lib/copy-sync/copy-sync.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
var fs = require('graceful-fs')
var path = require('path')
var copyFileSync = require('./copy-file-sync')
var mkdir = require('../mkdirs')
function copySync (src, dest, options) {
if (typeof options === 'function' || options instanceof RegExp) {
options = {filter: options}
}
options = options || {}
options.recursive = !!options.recursive
// default to true for now
options.clobber = 'clobber' in options ? !!options.clobber : true
options.preserveTimestamps = 'preserveTimestamps' in options ? !!options.preserveTimestamps : false
options.filter = options.filter || function () { return true }
var stats = options.recursive ? fs.lstatSync(src) : fs.statSync(src)
var destFolder = path.dirname(dest)
var destFolderExists = fs.existsSync(destFolder)
var performCopy = false
if (stats.isFile()) {
if (options.filter instanceof RegExp) performCopy = options.filter.test(src)
else if (typeof options.filter === 'function') performCopy = options.filter(src)
if (performCopy) {
if (!destFolderExists) mkdir.mkdirsSync(destFolder)
copyFileSync(src, dest, {clobber: options.clobber, preserveTimestamps: options.preserveTimestamps})
}
} else if (stats.isDirectory()) {
if (!fs.existsSync(dest)) mkdir.mkdirsSync(dest)
var contents = fs.readdirSync(src)
contents.forEach(function (content) {
var opts = options
opts.recursive = true
copySync(path.join(src, content), path.join(dest, content), opts)
})
} else if (options.recursive && stats.isSymbolicLink()) {
var srcPath = fs.readlinkSync(src)
fs.symlinkSync(srcPath, dest)
}
}
module.exports = copySync

3
node_modules/fs-extra/lib/copy-sync/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
copySync: require('./copy-sync')
}

44
node_modules/fs-extra/lib/copy/copy.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
var fs = require('graceful-fs')
var path = require('path')
var ncp = require('./ncp')
var mkdir = require('../mkdirs')
function copy (src, dest, options, callback) {
if (typeof options === 'function' && !callback) {
callback = options
options = {}
} else if (typeof options === 'function' || options instanceof RegExp) {
options = {filter: options}
}
callback = callback || function () {}
options = options || {}
// don't allow src and dest to be the same
var basePath = process.cwd()
var currentPath = path.resolve(basePath, src)
var targetPath = path.resolve(basePath, dest)
if (currentPath === targetPath) return callback(new Error('Source and destination must not be the same.'))
fs.lstat(src, function (err, stats) {
if (err) return callback(err)
var dir = null
if (stats.isDirectory()) {
var parts = dest.split(path.sep)
parts.pop()
dir = parts.join(path.sep)
} else {
dir = path.dirname(dest)
}
fs.exists(dir, function (dirExists) {
if (dirExists) return ncp(src, dest, options, callback)
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
ncp(src, dest, options, callback)
})
})
})
}
module.exports = copy

3
node_modules/fs-extra/lib/copy/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
copy: require('./copy')
}

243
node_modules/fs-extra/lib/copy/ncp.js generated vendored Normal file
View File

@@ -0,0 +1,243 @@
// imported from ncp (this is temporary, will rewrite)
var fs = require('graceful-fs')
var path = require('path')
var utimes = require('../util/utimes')
function ncp (source, dest, options, callback) {
if (!callback) {
callback = options
options = {}
}
var basePath = process.cwd()
var currentPath = path.resolve(basePath, source)
var targetPath = path.resolve(basePath, dest)
var filter = options.filter
var transform = options.transform
var clobber = options.clobber !== false
var dereference = options.dereference
var preserveTimestamps = options.preserveTimestamps === true
var errs = null
var started = 0
var finished = 0
var running = 0
// this is pretty useless now that we're using graceful-fs
// consider removing
var limit = options.limit || 512
startCopy(currentPath)
function startCopy (source) {
started++
if (filter) {
if (filter instanceof RegExp) {
if (!filter.test(source)) {
return doneOne(true)
}
} else if (typeof filter === 'function') {
if (!filter(source)) {
return doneOne(true)
}
}
}
return getStats(source)
}
function getStats (source) {
var stat = dereference ? fs.stat : fs.lstat
if (running >= limit) {
return setImmediate(function () {
getStats(source)
})
}
running++
stat(source, function (err, stats) {
if (err) return onError(err)
// We need to get the mode from the stats object and preserve it.
var item = {
name: source,
mode: stats.mode,
mtime: stats.mtime, // modified time
atime: stats.atime, // access time
stats: stats // temporary
}
if (stats.isDirectory()) {
return onDir(item)
} else if (stats.isFile() || stats.isCharacterDevice() || stats.isBlockDevice()) {
return onFile(item)
} else if (stats.isSymbolicLink()) {
// Symlinks don't really need to know about the mode.
return onLink(source)
}
})
}
function onFile (file) {
var target = file.name.replace(currentPath, targetPath)
isWritable(target, function (writable) {
if (writable) {
copyFile(file, target)
} else {
if (clobber) {
rmFile(target, function () {
copyFile(file, target)
})
} else {
doneOne()
}
}
})
}
function copyFile (file, target) {
var readStream = fs.createReadStream(file.name)
var writeStream = fs.createWriteStream(target, { mode: file.mode })
readStream.on('error', onError)
writeStream.on('error', onError)
if (transform) {
transform(readStream, writeStream, file)
} else {
writeStream.on('open', function () {
readStream.pipe(writeStream)
})
}
writeStream.once('finish', function () {
fs.chmod(target, file.mode, function (err) {
if (err) return onError(err)
if (preserveTimestamps) {
utimes.utimesMillis(target, file.atime, file.mtime, function (err) {
if (err) return onError(err)
return doneOne()
})
} else {
doneOne()
}
})
})
}
function rmFile (file, done) {
fs.unlink(file, function (err) {
if (err) return onError(err)
return done()
})
}
function onDir (dir) {
var target = dir.name.replace(currentPath, targetPath)
isWritable(target, function (writable) {
if (writable) {
return mkDir(dir, target)
}
copyDir(dir.name)
})
}
function mkDir (dir, target) {
fs.mkdir(target, dir.mode, function (err) {
if (err) return onError(err)
// despite setting mode in fs.mkdir, doesn't seem to work
// so we set it here.
fs.chmod(target, dir.mode, function (err) {
if (err) return onError(err)
copyDir(dir.name)
})
})
}
function copyDir (dir) {
fs.readdir(dir, function (err, items) {
if (err) return onError(err)
items.forEach(function (item) {
startCopy(path.join(dir, item))
})
return doneOne()
})
}
function onLink (link) {
var target = link.replace(currentPath, targetPath)
fs.readlink(link, function (err, resolvedPath) {
if (err) return onError(err)
checkLink(resolvedPath, target)
})
}
function checkLink (resolvedPath, target) {
if (dereference) {
resolvedPath = path.resolve(basePath, resolvedPath)
}
isWritable(target, function (writable) {
if (writable) {
return makeLink(resolvedPath, target)
}
fs.readlink(target, function (err, targetDest) {
if (err) return onError(err)
if (dereference) {
targetDest = path.resolve(basePath, targetDest)
}
if (targetDest === resolvedPath) {
return doneOne()
}
return rmFile(target, function () {
makeLink(resolvedPath, target)
})
})
})
}
function makeLink (linkPath, target) {
fs.symlink(linkPath, target, function (err) {
if (err) return onError(err)
return doneOne()
})
}
function isWritable (path, done) {
fs.lstat(path, function (err) {
if (err) {
if (err.code === 'ENOENT') return done(true)
return done(false)
}
return done(false)
})
}
function onError (err) {
if (options.stopOnError) {
return callback(err)
} else if (!errs && options.errs) {
errs = fs.createWriteStream(options.errs)
} else if (!errs) {
errs = []
}
if (typeof errs.write === 'undefined') {
errs.push(err)
} else {
errs.write(err.stack + '\n\n')
}
return doneOne()
}
function doneOne (skipped) {
if (!skipped) running--
finished++
if ((started === finished) && (running === 0)) {
if (callback !== undefined) {
return errs ? callback(errs) : callback(null)
}
}
}
}
module.exports = ncp

47
node_modules/fs-extra/lib/empty/index.js generated vendored Normal file
View File

@@ -0,0 +1,47 @@
var fs = require('fs')
var path = require('path')
var mkdir = require('../mkdirs')
var remove = require('../remove')
function emptyDir (dir, callback) {
callback = callback || function () {}
fs.readdir(dir, function (err, items) {
if (err) return mkdir.mkdirs(dir, callback)
items = items.map(function (item) {
return path.join(dir, item)
})
deleteItem()
function deleteItem () {
var item = items.pop()
if (!item) return callback()
remove.remove(item, function (err) {
if (err) return callback(err)
deleteItem()
})
}
})
}
function emptyDirSync (dir) {
var items
try {
items = fs.readdirSync(dir)
} catch (err) {
return mkdir.mkdirsSync(dir)
}
items.forEach(function (item) {
item = path.join(dir, item)
remove.removeSync(item)
})
}
module.exports = {
emptyDirSync: emptyDirSync,
emptydirSync: emptyDirSync,
emptyDir: emptyDir,
emptydir: emptyDir
}

43
node_modules/fs-extra/lib/ensure/file.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
var path = require('path')
var fs = require('graceful-fs')
var mkdir = require('../mkdirs')
function createFile (file, callback) {
function makeFile () {
fs.writeFile(file, '', function (err) {
if (err) return callback(err)
callback()
})
}
fs.exists(file, function (fileExists) {
if (fileExists) return callback()
var dir = path.dirname(file)
fs.exists(dir, function (dirExists) {
if (dirExists) return makeFile()
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
makeFile()
})
})
})
}
function createFileSync (file) {
if (fs.existsSync(file)) return
var dir = path.dirname(file)
if (!fs.existsSync(dir)) {
mkdir.mkdirsSync(dir)
}
fs.writeFileSync(file, '')
}
module.exports = {
createFile: createFile,
createFileSync: createFileSync,
// alias
ensureFile: createFile,
ensureFileSync: createFileSync
}

21
node_modules/fs-extra/lib/ensure/index.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
var file = require('./file')
var link = require('./link')
var symlink = require('./symlink')
module.exports = {
// file
createFile: file.createFile,
createFileSync: file.createFileSync,
ensureFile: file.createFile,
ensureFileSync: file.createFileSync,
// link
createLink: link.createLink,
createLinkSync: link.createLinkSync,
ensureLink: link.createLink,
ensureLinkSync: link.createLinkSync,
// symlink
createSymlink: symlink.createSymlink,
createSymlinkSync: symlink.createSymlinkSync,
ensureSymlink: symlink.createSymlink,
ensureSymlinkSync: symlink.createSymlinkSync
}

58
node_modules/fs-extra/lib/ensure/link.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
var path = require('path')
var fs = require('graceful-fs')
var mkdir = require('../mkdirs')
function createLink (srcpath, dstpath, callback) {
function makeLink (srcpath, dstpath) {
fs.link(srcpath, dstpath, function (err) {
if (err) return callback(err)
callback(null)
})
}
fs.exists(dstpath, function (destinationExists) {
if (destinationExists) return callback(null)
fs.lstat(srcpath, function (err, stat) {
if (err) {
err.message = err.message.replace('lstat', 'ensureLink')
return callback(err)
}
var dir = path.dirname(dstpath)
fs.exists(dir, function (dirExists) {
if (dirExists) return makeLink(srcpath, dstpath)
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
makeLink(srcpath, dstpath)
})
})
})
})
}
function createLinkSync (srcpath, dstpath, callback) {
var destinationExists = fs.existsSync(dstpath)
if (destinationExists) return undefined
try {
fs.lstatSync(srcpath)
} catch (err) {
err.message = err.message.replace('lstat', 'ensureLink')
throw err
}
var dir = path.dirname(dstpath)
var dirExists = fs.existsSync(dir)
if (dirExists) return fs.linkSync(srcpath, dstpath)
mkdir.mkdirsSync(dir)
return fs.linkSync(srcpath, dstpath)
}
module.exports = {
createLink: createLink,
createLinkSync: createLinkSync,
// alias
ensureLink: createLink,
ensureLinkSync: createLinkSync
}

97
node_modules/fs-extra/lib/ensure/symlink-paths.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
var path = require('path')
// path.isAbsolute shim for Node.js 0.10 support
path.isAbsolute = (path.isAbsolute) ? path.isAbsolute : require('path-is-absolute')
var fs = require('graceful-fs')
/**
* Function that returns two types of paths, one relative to symlink, and one
* relative to the current working directory. Checks if path is absolute or
* relative. If the path is relative, this function checks if the path is
* relative to symlink or relative to current working directory. This is an
* initiative to find a smarter `srcpath` to supply when building symlinks.
* This allows you to determine which path to use out of one of three possible
* types of source paths. The first is an absolute path. This is detected by
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
* see if it exists. If it does it's used, if not an error is returned
* (callback)/ thrown (sync). The other two options for `srcpath` are a
* relative url. By default Node's `fs.symlink` works by creating a symlink
* using `dstpath` and expects the `srcpath` to be relative to the newly
* created symlink. If you provide a `srcpath` that does not exist on the file
* system it results in a broken symlink. To minimize this, the function
* checks to see if the 'relative to symlink' source file exists, and if it
* does it will use it. If it does not, it checks if there's a file that
* exists that is relative to the current working directory, if does its used.
* This preserves the expectations of the original fs.symlink spec and adds
* the ability to pass in `relative to current working direcotry` paths.
*/
function symlinkPaths (srcpath, dstpath, callback) {
if (path.isAbsolute(srcpath)) {
return fs.lstat(srcpath, function (err, stat) {
if (err) {
err.message = err.message.replace('lstat', 'ensureSymlink')
return callback(err)
}
return callback(null, {
'toCwd': srcpath,
'toDst': srcpath
})
})
} else {
var dstdir = path.dirname(dstpath)
var relativeToDst = path.join(dstdir, srcpath)
return fs.exists(relativeToDst, function (exists) {
if (exists) {
return callback(null, {
'toCwd': relativeToDst,
'toDst': srcpath
})
} else {
return fs.lstat(srcpath, function (err, stat) {
if (err) {
err.message = err.message.replace('lstat', 'ensureSymlink')
return callback(err)
}
return callback(null, {
'toCwd': srcpath,
'toDst': path.relative(dstdir, srcpath)
})
})
}
})
}
}
function symlinkPathsSync (srcpath, dstpath) {
var exists
if (path.isAbsolute(srcpath)) {
exists = fs.existsSync(srcpath)
if (!exists) throw new Error('absolute srcpath does not exist')
return {
'toCwd': srcpath,
'toDst': srcpath
}
} else {
var dstdir = path.dirname(dstpath)
var relativeToDst = path.join(dstdir, srcpath)
exists = fs.existsSync(relativeToDst)
if (exists) {
return {
'toCwd': relativeToDst,
'toDst': srcpath
}
} else {
exists = fs.existsSync(srcpath)
if (!exists) throw new Error('relative srcpath does not exist')
return {
'toCwd': srcpath,
'toDst': path.relative(dstdir, srcpath)
}
}
}
}
module.exports = {
'symlinkPaths': symlinkPaths,
'symlinkPathsSync': symlinkPathsSync
}

27
node_modules/fs-extra/lib/ensure/symlink-type.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
var fs = require('graceful-fs')
function symlinkType (srcpath, type, callback) {
callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type
if (type) return callback(null, type)
fs.lstat(srcpath, function (err, stats) {
if (err) return callback(null, 'file')
type = (stats && stats.isDirectory()) ? 'dir' : 'file'
callback(null, type)
})
}
function symlinkTypeSync (srcpath, type) {
if (type) return type
try {
var stats = fs.lstatSync(srcpath)
} catch (e) {
return 'file'
}
return (stats && stats.isDirectory()) ? 'dir' : 'file'
}
module.exports = {
symlinkType: symlinkType,
symlinkTypeSync: symlinkTypeSync
}

62
node_modules/fs-extra/lib/ensure/symlink.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
var path = require('path')
var fs = require('graceful-fs')
var _mkdirs = require('../mkdirs')
var mkdirs = _mkdirs.mkdirs
var mkdirsSync = _mkdirs.mkdirsSync
var _symlinkPaths = require('./symlink-paths')
var symlinkPaths = _symlinkPaths.symlinkPaths
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync
var _symlinkType = require('./symlink-type')
var symlinkType = _symlinkType.symlinkType
var symlinkTypeSync = _symlinkType.symlinkTypeSync
function createSymlink (srcpath, dstpath, type, callback) {
callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type
fs.exists(dstpath, function (destinationExists) {
if (destinationExists) return callback(null)
symlinkPaths(srcpath, dstpath, function (err, relative) {
if (err) return callback(err)
srcpath = relative.toDst
symlinkType(relative.toCwd, type, function (err, type) {
if (err) return callback(err)
var dir = path.dirname(dstpath)
fs.exists(dir, function (dirExists) {
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback)
mkdirs(dir, function (err) {
if (err) return callback(err)
fs.symlink(srcpath, dstpath, type, callback)
})
})
})
})
})
}
function createSymlinkSync (srcpath, dstpath, type, callback) {
callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type
var destinationExists = fs.existsSync(dstpath)
if (destinationExists) return undefined
var relative = symlinkPathsSync(srcpath, dstpath)
srcpath = relative.toDst
type = symlinkTypeSync(relative.toCwd, type)
var dir = path.dirname(dstpath)
var exists = fs.existsSync(dir)
if (exists) return fs.symlinkSync(srcpath, dstpath, type)
mkdirsSync(dir)
return fs.symlinkSync(srcpath, dstpath, type)
}
module.exports = {
createSymlink: createSymlink,
createSymlinkSync: createSymlinkSync,
// alias
ensureSymlink: createSymlink,
ensureSymlinkSync: createSymlinkSync
}

38
node_modules/fs-extra/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
var assign = require('./util/assign')
var fse = {}
var gfs = require('graceful-fs')
// attach fs methods to fse
Object.keys(gfs).forEach(function (key) {
fse[key] = gfs[key]
})
var fs = fse
assign(fs, require('./copy'))
assign(fs, require('./copy-sync'))
assign(fs, require('./mkdirs'))
assign(fs, require('./remove'))
assign(fs, require('./json'))
assign(fs, require('./move'))
assign(fs, require('./streams'))
assign(fs, require('./empty'))
assign(fs, require('./ensure'))
assign(fs, require('./output'))
assign(fs, require('./walk'))
module.exports = fs
// maintain backwards compatibility for awhile
var jsonfile = {}
Object.defineProperty(jsonfile, 'spaces', {
get: function () {
return fs.spaces // found in ./json
},
set: function (val) {
fs.spaces = val
}
})
module.exports.jsonfile = jsonfile // so users of fs-extra can modify jsonFile.spaces

9
node_modules/fs-extra/lib/json/index.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
var jsonFile = require('./jsonfile')
jsonFile.outputJsonSync = require('./output-json-sync')
jsonFile.outputJson = require('./output-json')
// aliases
jsonFile.outputJSONSync = require('./output-json-sync')
jsonFile.outputJSON = require('./output-json')
module.exports = jsonFile

14
node_modules/fs-extra/lib/json/jsonfile.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var jsonFile = require('jsonfile')
module.exports = {
// jsonfile exports
readJson: jsonFile.readFile,
readJSON: jsonFile.readFile,
readJsonSync: jsonFile.readFileSync,
readJSONSync: jsonFile.readFileSync,
writeJson: jsonFile.writeFile,
writeJSON: jsonFile.writeFile,
writeJsonSync: jsonFile.writeFileSync,
writeJSONSync: jsonFile.writeFileSync,
spaces: 2 // default in fs-extra
}

16
node_modules/fs-extra/lib/json/output-json-sync.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
var fs = require('graceful-fs')
var path = require('path')
var jsonFile = require('./jsonfile')
var mkdir = require('../mkdirs')
function outputJsonSync (file, data, options) {
var dir = path.dirname(file)
if (!fs.existsSync(dir)) {
mkdir.mkdirsSync(dir)
}
jsonFile.writeJsonSync(file, data, options)
}
module.exports = outputJsonSync

24
node_modules/fs-extra/lib/json/output-json.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
var fs = require('graceful-fs')
var path = require('path')
var jsonFile = require('./jsonfile')
var mkdir = require('../mkdirs')
function outputJson (file, data, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
var dir = path.dirname(file)
fs.exists(dir, function (itDoes) {
if (itDoes) return jsonFile.writeJson(file, data, options, callback)
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
jsonFile.writeJson(file, data, options, callback)
})
})
}
module.exports = outputJson

9
node_modules/fs-extra/lib/mkdirs/index.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
module.exports = {
mkdirs: require('./mkdirs'),
mkdirsSync: require('./mkdirs-sync'),
// alias
mkdirp: require('./mkdirs'),
mkdirpSync: require('./mkdirs-sync'),
ensureDir: require('./mkdirs'),
ensureDirSync: require('./mkdirs-sync')
}

49
node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
var fs = require('graceful-fs')
var path = require('path')
var o777 = parseInt('0777', 8)
function mkdirsSync (p, opts, made) {
if (!opts || typeof opts !== 'object') {
opts = { mode: opts }
}
var mode = opts.mode
var xfs = opts.fs || fs
if (mode === undefined) {
mode = o777 & (~process.umask())
}
if (!made) made = null
p = path.resolve(p)
try {
xfs.mkdirSync(p, mode)
made = made || p
} catch (err0) {
switch (err0.code) {
case 'ENOENT' :
made = mkdirsSync(path.dirname(p), opts, made)
mkdirsSync(p, opts, made)
break
// In the case of any other error, just see if there's a dir
// there already. If so, then hooray! If not, then something
// is borked.
default:
var stat
try {
stat = xfs.statSync(p)
} catch (err1) {
throw err0
}
if (!stat.isDirectory()) throw err0
break
}
}
return made
}
module.exports = mkdirsSync

54
node_modules/fs-extra/lib/mkdirs/mkdirs.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
var fs = require('graceful-fs')
var path = require('path')
var o777 = parseInt('0777', 8)
function mkdirs (p, opts, callback, made) {
if (typeof opts === 'function') {
callback = opts
opts = {}
} else if (!opts || typeof opts !== 'object') {
opts = { mode: opts }
}
var mode = opts.mode
var xfs = opts.fs || fs
if (mode === undefined) {
mode = o777 & (~process.umask())
}
if (!made) made = null
callback = callback || function () {}
p = path.resolve(p)
xfs.mkdir(p, mode, function (er) {
if (!er) {
made = made || p
return callback(null, made)
}
switch (er.code) {
case 'ENOENT':
if (path.dirname(p) === p) return callback(er)
mkdirs(path.dirname(p), opts, function (er, made) {
if (er) callback(er, made)
else mkdirs(p, opts, callback, made)
})
break
// In the case of any other error, just see if there's a dir
// there already. If so, then hooray! If not, then something
// is borked.
default:
xfs.stat(p, function (er2, stat) {
// if the stat fails, then that's super weird.
// let the original error be the failure reason.
if (er2 || !stat.isDirectory()) callback(er, made)
else callback(null, made)
})
break
}
})
}
module.exports = mkdirs

161
node_modules/fs-extra/lib/move/index.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
// most of this code was written by Andrew Kelley
// licensed under the BSD license: see
// https://github.com/andrewrk/node-mv/blob/master/package.json
// this needs a cleanup
var fs = require('graceful-fs')
var ncp = require('../copy/ncp')
var path = require('path')
var rimraf = require('rimraf')
var mkdirp = require('../mkdirs').mkdirs
function mv (source, dest, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}
var shouldMkdirp = ('mkdirp' in options) ? options.mkdirp : true
var clobber = ('clobber' in options) ? options.clobber : false
var limit = options.limit || 16
if (shouldMkdirp) {
mkdirs()
} else {
doRename()
}
function mkdirs () {
mkdirp(path.dirname(dest), function (err) {
if (err) return callback(err)
doRename()
})
}
function doRename () {
if (clobber) {
fs.rename(source, dest, function (err) {
if (!err) return callback()
if (err.code === 'ENOTEMPTY' || err.code === 'EEXIST') {
rimraf(dest, function (err) {
if (err) return callback(err)
options.clobber = false // just clobbered it, no need to do it again
mv(source, dest, options, callback)
})
return
}
// weird Windows shit
if (err.code === 'EPERM') {
setTimeout(function () {
rimraf(dest, function (err) {
if (err) return callback(err)
options.clobber = false
mv(source, dest, options, callback)
})
}, 200)
return
}
if (err.code !== 'EXDEV') return callback(err)
moveAcrossDevice(source, dest, clobber, limit, callback)
})
} else {
fs.link(source, dest, function (err) {
if (err) {
if (err.code === 'EXDEV' || err.code === 'EISDIR' || err.code === 'EPERM') {
moveAcrossDevice(source, dest, clobber, limit, callback)
return
}
callback(err)
return
}
fs.unlink(source, callback)
})
}
}
}
function moveAcrossDevice (source, dest, clobber, limit, callback) {
fs.stat(source, function (err, stat) {
if (err) {
callback(err)
return
}
if (stat.isDirectory()) {
moveDirAcrossDevice(source, dest, clobber, limit, callback)
} else {
moveFileAcrossDevice(source, dest, clobber, limit, callback)
}
})
}
function moveFileAcrossDevice (source, dest, clobber, limit, callback) {
var outFlags = clobber ? 'w' : 'wx'
var ins = fs.createReadStream(source)
var outs = fs.createWriteStream(dest, {flags: outFlags})
ins.on('error', function (err) {
ins.destroy()
outs.destroy()
outs.removeListener('close', onClose)
// may want to create a directory but `out` line above
// creates an empty file for us: See #108
// don't care about error here
fs.unlink(dest, function () {
// note: `err` here is from the input stream errror
if (err.code === 'EISDIR' || err.code === 'EPERM') {
moveDirAcrossDevice(source, dest, clobber, limit, callback)
} else {
callback(err)
}
})
})
outs.on('error', function (err) {
ins.destroy()
outs.destroy()
outs.removeListener('close', onClose)
callback(err)
})
outs.once('close', onClose)
ins.pipe(outs)
function onClose () {
fs.unlink(source, callback)
}
}
function moveDirAcrossDevice (source, dest, clobber, limit, callback) {
var options = {
stopOnErr: true,
clobber: false,
limit: limit
}
function startNcp () {
ncp(source, dest, options, function (errList) {
if (errList) return callback(errList[0])
rimraf(source, callback)
})
}
if (clobber) {
rimraf(dest, function (err) {
if (err) return callback(err)
startNcp()
})
} else {
startNcp()
}
}
module.exports = {
move: mv
}

35
node_modules/fs-extra/lib/output/index.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
var path = require('path')
var fs = require('graceful-fs')
var mkdir = require('../mkdirs')
function outputFile (file, data, encoding, callback) {
if (typeof encoding === 'function') {
callback = encoding
encoding = 'utf8'
}
var dir = path.dirname(file)
fs.exists(dir, function (itDoes) {
if (itDoes) return fs.writeFile(file, data, encoding, callback)
mkdir.mkdirs(dir, function (err) {
if (err) return callback(err)
fs.writeFile(file, data, encoding, callback)
})
})
}
function outputFileSync (file, data, encoding) {
var dir = path.dirname(file)
if (fs.existsSync(dir)) {
return fs.writeFileSync.apply(fs, arguments)
}
mkdir.mkdirsSync(dir)
fs.writeFileSync.apply(fs, arguments)
}
module.exports = {
outputFile: outputFile,
outputFileSync: outputFileSync
}

14
node_modules/fs-extra/lib/remove/index.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
var rimraf = require('rimraf')
function removeSync (dir) {
return rimraf.sync(dir)
}
function remove (dir, callback) {
return callback ? rimraf(dir, callback) : rimraf(dir, function () {})
}
module.exports = {
remove: remove,
removeSync: removeSync
}

View File

@@ -0,0 +1,43 @@
var path = require('path')
var fs = require('fs')
var mkdir = require('../mkdirs')
var WriteStream = fs.WriteStream
function createOutputStream (file, options) {
var dirExists = false
var dir = path.dirname(file)
options = options || {}
// if fd is set with an actual number, file is created, hence directory is too
if (options.fd) {
return fs.createWriteStream(file, options)
} else {
// this hacks the WriteStream constructor from calling open()
options.fd = -1
}
var ws = new WriteStream(file, options)
var oldOpen = ws.open
ws.open = function () {
ws.fd = null // set actual fd
if (dirExists) return oldOpen.call(ws)
// this only runs once on first write
mkdir.mkdirs(dir, function (err) {
if (err) {
ws.destroy()
ws.emit('error', err)
return
}
dirExists = true
oldOpen.call(ws)
})
}
ws.open()
return ws
}
module.exports = createOutputStream

3
node_modules/fs-extra/lib/streams/index.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
createOutputStream: require('./create-output-stream')
}

14
node_modules/fs-extra/lib/util/assign.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
// simple mutable assign
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
}
module.exports = assign

69
node_modules/fs-extra/lib/util/utimes.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
var fs = require('graceful-fs')
var path = require('path')
var os = require('os')
// HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
function hasMillisResSync () {
var tmpfile = path.join('millis-test-sync' + Date.now().toString() + Math.random().toString().slice(2))
tmpfile = path.join(os.tmpdir(), tmpfile)
// 550 millis past UNIX epoch
var d = new Date(1435410243862)
fs.writeFileSync(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141')
var fd = fs.openSync(tmpfile, 'r+')
fs.futimesSync(fd, d, d)
fs.closeSync(fd)
return fs.statSync(tmpfile).mtime > 1435410243000
}
function hasMillisRes (callback) {
var tmpfile = path.join('millis-test' + Date.now().toString() + Math.random().toString().slice(2))
tmpfile = path.join(os.tmpdir(), tmpfile)
// 550 millis past UNIX epoch
var d = new Date(1435410243862)
fs.writeFile(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141', function (err) {
if (err) return callback(err)
fs.open(tmpfile, 'r+', function (err, fd) {
if (err) return callback(err)
fs.futimes(fd, d, d, function (err) {
if (err) return callback(err)
fs.close(fd, function (err) {
if (err) return callback(err)
fs.stat(tmpfile, function (err, stats) {
if (err) return callback(err)
callback(null, stats.mtime > 1435410243000)
})
})
})
})
})
}
function timeRemoveMillis (timestamp) {
if (typeof timestamp === 'number') {
return Math.floor(timestamp / 1000) * 1000
} else if (timestamp instanceof Date) {
return new Date(Math.floor(timestamp.getTime() / 1000) * 1000)
} else {
throw new Error('fs-extra: timeRemoveMillis() unknown parameter type')
}
}
function utimesMillis (path, atime, mtime, callback) {
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
fs.open(path, 'r+', function (err, fd) {
if (err) return callback(err)
fs.futimes(fd, atime, mtime, function (err) {
if (err) return callback(err)
fs.close(fd, callback)
})
})
}
module.exports = {
hasMillisRes: hasMillisRes,
hasMillisResSync: hasMillisResSync,
timeRemoveMillis: timeRemoveMillis,
utimesMillis: utimesMillis
}

5
node_modules/fs-extra/lib/walk/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
var klaw = require('klaw')
module.exports = {
walk: klaw
}

15
node_modules/fs-extra/node_modules/graceful-fs/LICENSE generated vendored Normal file
View 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.

View 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

View 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
}

View 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)
}
}

View 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();
}
}
}

View File

@@ -0,0 +1,120 @@
{
"_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"
]
],
"_from": "graceful-fs@>=4.1.2 <5.0.0",
"_hasShrinkwrap": false,
"_id": "graceful-fs@4.2.11",
"_inCache": true,
"_installable": true,
"_location": "/fs-extra/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.2",
"rawSpec": "^4.1.2",
"scope": null,
"spec": ">=4.1.2 <5.0.0",
"type": "range"
},
"_requiredBy": [
"/fs-extra"
],
"_resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
"_shasum": "4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3",
"_shrinkwrap": null,
"_spec": "graceful-fs@^4.1.2",
"_where": "/root/gitbook/node_modules/fs-extra",
"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"
}

View 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
}
}

131
node_modules/fs-extra/package.json generated vendored Normal file
View File

@@ -0,0 +1,131 @@
{
"_args": [
[
{
"name": "fs-extra",
"raw": "fs-extra@~0.26.4",
"rawSpec": "~0.26.4",
"scope": null,
"spec": ">=0.26.4 <0.27.0",
"type": "range"
},
"/root/gitbook/node_modules/phantomjs"
]
],
"_from": "fs-extra@>=0.26.4 <0.27.0",
"_id": "fs-extra@0.26.7",
"_inCache": true,
"_installable": true,
"_location": "/fs-extra",
"_nodeVersion": "5.3.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/fs-extra-0.26.7.tgz_1458137480601_0.30359794734977186"
},
"_npmUser": {
"email": "jprichardson@gmail.com",
"name": "jprichardson"
},
"_npmVersion": "3.7.1",
"_phantomChildren": {},
"_requested": {
"name": "fs-extra",
"raw": "fs-extra@~0.26.4",
"rawSpec": "~0.26.4",
"scope": null,
"spec": ">=0.26.4 <0.27.0",
"type": "range"
},
"_requiredBy": [
"/phantomjs"
],
"_resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz",
"_shasum": "9ae1fdd94897798edab76d0918cf42d0c3184fa9",
"_shrinkwrap": null,
"_spec": "fs-extra@~0.26.4",
"_where": "/root/gitbook/node_modules/phantomjs",
"author": {
"email": "jprichardson@gmail.com",
"name": "JP Richardson"
},
"bugs": {
"url": "https://github.com/jprichardson/node-fs-extra/issues"
},
"dependencies": {
"graceful-fs": "^4.1.2",
"jsonfile": "^2.1.0",
"klaw": "^1.0.0",
"path-is-absolute": "^1.0.0",
"rimraf": "^2.2.8"
},
"description": "fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as mkdir -p, cp -r, and rm -rf.",
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.5",
"minimist": "^1.1.1",
"mocha": "^2.1.0",
"read-dir-files": "^0.1.1",
"secure-random": "^1.1.1",
"semver": "^4.3.6",
"standard": "^5.3.1"
},
"directories": {},
"dist": {
"integrity": "sha512-waKu+1KumRhYv8D8gMRCKJGAMI9pRnPuEb1mvgYD0f7wBscg+h6bW4FDTmEZhB9VKxvoTtxW+Y7bnIlB7zja6Q==",
"shasum": "9ae1fdd94897798edab76d0918cf42d0c3184fa9",
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEQCIDbio6bwTuRHqfpd9pMjp8t3ivMOxVkhG0C+RbX9/UasAiBYz3a+YcXewq6Sebu4bXEARHrxv032KU5OVergRkiwdA=="
}
],
"tarball": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.26.7.tgz"
},
"gitHead": "1cde1961f2e971cb42060384312c5faa419c9792",
"homepage": "https://github.com/jprichardson/node-fs-extra",
"keywords": [
"fs",
"file",
"file system",
"copy",
"directory",
"extra",
"mkdirp",
"mkdir",
"mkdirs",
"recursive",
"json",
"read",
"write",
"extra",
"delete",
"remove",
"touch",
"create",
"text",
"output",
"move"
],
"license": "MIT",
"main": "./lib/index",
"maintainers": [
{
"email": "jprichardson@gmail.com",
"name": "jprichardson"
}
],
"name": "fs-extra",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/jprichardson/node-fs-extra.git"
},
"scripts": {
"coverage": "istanbul cover test.js",
"coveralls": "npm run coverage && coveralls < coverage/lcov.info",
"test": "standard && node test.js",
"test-find": "find ./lib/**/__tests__ -name *.test.js | xargs mocha"
},
"version": "0.26.7"
}