Skip to content

Commit

Permalink
remove direct cache access, fixes #113
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed May 12, 2020
1 parent 680ca53 commit 244ccf7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/mockModule.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Module, {getModuleParent} from './module';
import wipeCache from './wipeCache';
import Module, {getModuleName, getModuleParent} from './module';
import wipeCache, {safelyRemoveCache} from './wipeCache';
import createScope from './scope';
import {getScopeVariable, setScope} from './globals';
import {
Expand Down Expand Up @@ -322,11 +322,12 @@ mockModule.clear = () => {
};

const cleanup = () => {
delete require.cache[require.resolve(__filename)];
safelyRemoveCache(getModuleName(module));
};


const addPlugin = (plugin) => {
plugin.init();
scope();
addPluginAPI(plugin);
};
Expand Down
4 changes: 3 additions & 1 deletion src/nested.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as API from './mockModule';
delete require.cache[require.resolve(__filename)];
import {safelyRemoveCache} from "./wipeCache";
import {getModuleName} from "./module";
safelyRemoveCache(getModuleName(module));
export default API.mockModule;

0 comments on commit 244ccf7

Please sign in to comment.