An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# fs-spy

[![NPM version](https://img.shields.io/npm/v/fs-spy?color=a1b858&label=)](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
```

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

```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)