blob: 765de10e8812859d904750576c4d8996863e432e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
var rewireModule = require("./rewire.js");
/**
* Adds a special setter and getter to the module located at filename. After the module has been rewired, you can
* call myModule.__set__(name, value) and myModule.__get__(name) to manipulate private variables.
*
* @param {!String} filename Path to the module that shall be rewired. Use it exactly like require().
* @return {*} the rewired module
*/
function rewire(filename, opts) {
return rewireModule(module.parent, filename, opts);
}
module.exports = rewire;
delete require.cache[__filename]; // deleting self from module cache so the parent module is always up to date
|