fs-spy
Monitoring fs accessing for Node process
Install
npm i -D fs-spy
Usage
node -r fs-spy my-module.js
For wrapped CLIs:
# NODE_OPTIONS=--require=fs-spy <command>
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
import spy from 'fs-spy'
spy.onFileEvent((event, filepath) => {
if (filepath.endsWith('.json'))
throw new Error('See the stack trace')
})
Sponsors
License
MIT License Β© 2022 Anthony Fu