/invalidate-require-cache

Delete modules in a folder from require.cache unless the folder is unchanged since last call

Primary LanguageJavaScriptMIT LicenseMIT

invalidate-require-cache

CircleCI Coverage Status semantic-release Commitizen friendly npm version

Delete modules in a folder from require.cache unless the folder is unchanged since last call.

This is used by jscodeshift-choose-parser to ensure that it always uses the current version of babel installed in a project.

const invalidateRequireCache = require('invalidate-require-cache')

invalidateRequireCache('path/to/directory')
// now everything inside that directory has been deleted from require.cache
// (unless it is unchanged since the last call)
// and will be reloaded if you require it again.