antfu / fs-spy

Monitoring fs accessing for Node process

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fs-spy

NPM version

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

image

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

About

Monitoring fs accessing for Node process

License:MIT License


Languages

Language:TypeScript 91.2%Language:JavaScript 8.8%