https://github.com/antfu/fs-spy
Monitoring fs accessing for Node process
https://github.com/antfu/fs-spy
filesystem fs
Last synced: about 1 year ago
JSON representation
Monitoring fs accessing for Node process
- Host: GitHub
- URL: https://github.com/antfu/fs-spy
- Owner: antfu
- License: mit
- Created: 2022-04-21T21:22:50.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-12T07:12:39.000Z (over 1 year ago)
- Last Synced: 2025-04-13T00:46:42.899Z (about 1 year ago)
- Topics: filesystem, fs
- Language: TypeScript
- Homepage:
- Size: 83 KB
- Stars: 174
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# fs-spy
[](https://www.npmjs.com/package/fs-spy)
Monitoring fs accessing for Node process
## Install
```bash
npm i -D fs-spy
```
## Usage
```bash
node -r fs-spy my-module.js
```
For wrapped CLIs:
```bash
# NODE_OPTIONS=--require=fs-spy
NODE_OPTIONS=--require=fs-spy rollup -c
```

On the process exit, you will get the accessed file tree report and a generated `.fs-spy.json` file under your current working directory.
## Debugging
You can use `fs-spy` to debug why certain file has be accessed by using the hook. For example
```ts
import spy from 'fs-spy'
spy.onFileEvent((event, filepath) => {
if (filepath.endsWith('.json'))
throw new Error('See the stack trace')
})
```
## Sponsors
## License
[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu)