You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.1 KiB

3 months ago
  1. # fs-monkey
  2. [![][npm-img]][npm-url] [![][travis-badge]][travis-url]
  3. Monkey-patches for filesystem related things.
  4. - Rewrite `require` function to load Node's modules from memory.
  5. - Or rewrite the whole `fs` filesystem module.
  6. ## Install
  7. ```shell
  8. npm install --save fs-monkey
  9. ```
  10. ## Terms
  11. An *fs-like* object is an object that implements methods of Node's
  12. [filesystem API](https://nodejs.org/api/fs.html).
  13. It is denoted as `vol`:
  14. ```js
  15. let vol = {
  16. readFile: () => { /* ... */ },
  17. readFileSync: () => { /* ... */ },
  18. // etc...
  19. }
  20. ```
  21. ## Reference
  22. - [`patchFs`](./docs/api/patchFs.md) - rewrites Node's filesystem module `fs` with *fs-like* object `vol`
  23. - [`patchRequire`](./docs/api/patchRequire.md) - rewrites `require` function, patches Node's `module` module to use a given *fs-like* object for module loading
  24. [npm-img]: https://img.shields.io/npm/v/fs-monkey.svg
  25. [npm-url]: https://www.npmjs.com/package/fs-monkey
  26. [travis-url]: https://travis-ci.org/streamich/fs-monkey
  27. [travis-badge]: https://travis-ci.org/streamich/fs-monkey.svg?branch=master
  28. ## License
  29. [Unlicense](./LICENSE) - public domain.