rcc

require-cache-control

Control require cache by taking snapshots and restoring previous state. Useful when testing code.

Showing:

Popularity

Downloads/wk

30

GitHub Stars

0

Maintenance

Last Commit

5yrs ago

Contributors

0

Package

Dependencies

0

Size (min+gzip)

0.2KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

require-cache-control

Build status Coverage

Let's you take a snapshot of the current require cache and restore it at will. This is useful if you want to test some files repeatadly in a single process.

Imagine you have a gulp process running and your testing plugin uses require() to test the files. After the first require, you won't be able to re-test your files because of the require cache.

This is the case with gulp-tape, it uses require-uncached to freshly load the the test files to work around this problem. The problem is require-uncached does not take care of subsequent requires. It only freshly loads the file that is given to it, if the file itself requires other files, they will be cached and won't be fresh.

Install


npm install require-cache-control

Usage


const rcc = require('require-cache-control');

// Assuming `tests` is a collection containing file names
for (let test of tests) {
  // Capture the state of the require cache§
  let snapshot = rcc.snapshot();
  require(test);
  // Restore to the captured state
  // `test` itself and all the require()s made by it will be removed from cache
  rcc.restore(snapshot); 
}

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial