Skip to content

Commit

Permalink
Fix only deleting test files chache instead of entire require cache
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderdeseyn committed Oct 31, 2020
1 parent 180e13c commit e77e6c9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extendConfig(
);

task("watch", "Start the file watcher").setAction(
async ({}, { run, tasks, config: { watcher } }) => {
async ({}, { run, tasks, config: { watcher, paths } }) => {
const logVerbose = (...messages: any) => {
if (watcher.verbose) console.log(...messages);
};
Expand Down Expand Up @@ -62,7 +62,9 @@ task("watch", "Start the file watcher").setAction(
await run(task.command, task.params);
// This hack is required to allow running Mocha commands. Check out https://github.com/mochajs/mocha/issues/1938 for more details.
Object.keys(require.cache).forEach(function (key) {
delete require.cache[key];
if (key.startsWith(paths.tests)) {
delete require.cache[key];
}
});
} catch (err) {
console.log(`Task "${task.command}" failed.`);
Expand Down

0 comments on commit e77e6c9

Please sign in to comment.