pit-require-cache 🐕
What is pit-require-cache? 🤷
pit-require-cache is a zero-configuration watcher that deletes require's
cache for any updated file.
Case of use 🖌
Lets say that you are importing trought require a specific file and then serving that file trought a express server, then you update that file and as require
cache the files already imported you need to stop the server and start it again.
With pit-require-cache
is not needed anymore, just instantiate the watcher once and then it will delete the cache for you making the changes appear all straight.
Instalation 🧱
npm install pit-require-cache
Usage 🐶
const watcher =
Available Options 🧪
const options = persistent: true ignored: '*.txt' ignoreInitial: false followSymlinks: true cwd: '.' disableGlobbing: false usePolling: true interval: 100 binaryInterval: 300 alwaysStat: false depth: 99 awaitWriteFinish: stabilityThreshold: 2000 pollInterval: 100 ignorePermissionErrors: false atomic: true
Main options:
directory Directory to be watched default: "." string or array of strings persistent Show version number default: true boolean ignored Ignored files default: '' string example: '*.txt' ignoreInitial Add/addDir events are also default: false boolean emitted while instantiating followSymlinks Watch followinf symbolic links default: true boolean cwd Base directory default: '.' string usePolling Whether to use fswatchFile or default: false boolean fswatchtrue interval Interval for polling default: 100 number binaryInterval Interval polling for binary filesdefault: 300 number depth Limits how many levels of subdirectories will be traversed default: undefined number awaitWriteFinish Wait until the size of the file default: undefined example: stays constant stabilityThreshold: 2000 pollInterval: 100 object ignorePermissionErrors Silence the access errors default: false boolean
As we are using chokidar
module for the watcher implementation, there are a couple more options that can be checked on chokidar
's module docs https://www.npmjs.com/package/chokidar/v/2.0.4