Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes <mail@johannesewald.de>2012-06-04 03:50:51 +0400
committerJohannes <mail@johannesewald.de>2012-06-04 03:58:01 +0400
commite63302250265c43084fa4b9923fd7e50710adc15 (patch)
treefc1cc76e9fac66ca1c2fb103bdea0172b4921429
parent3cef6560f191b6647033f470b631762845b6f476 (diff)
added documentation
-rw-r--r--README.md2
-rw-r--r--lib/rewire.js4
2 files changed, 3 insertions, 3 deletions
diff --git a/README.md b/README.md
index ec73674..f9db54c 100644
--- a/README.md
+++ b/README.md
@@ -101,7 +101,7 @@ rewire("./myModuleA.js", null, null, null, false) !== require("./myModuleA.js");
- *{!String} filename*: Path to the module that shall be rewired. Use it exactly like require().
- *{Object} mocks (optional)*: An object with mocks. Keys should be the exactly the same like they're required in the target module. So if you write ```require("../../myModules/myModuleA.js")``` you need to pass ```{"../../myModules/myModuleA.js": myModuleAMock}```.
-- *{Object|String} injections (optional)*: If you pass an object, all keys of the object will be ```var```s within the module. You can also eval a string. **Please note**: All scripts are injected at the end of the module. So if there is any code in your module that is executed during ```require()```, your injected variables will be undefined at this point. For example: passing ```{console: {...}}``` will cause all calls of ```console.log()``` to throw an exception if they're executed during ```require()```.
+- *{Object|String} injections (optional)*: If you pass an object, all keys of the object will be ```var```s within the module. You can also eval a string. **Please note**: All scripts are injected at the end of the module. So if there is any code in your module that is executed during ```require()```, your injected variables will be undefined at this point. For example: passing ```{console: null}``` will cause all calls of ```console.log()``` to throw an exception if they're executed during ```require()```.
- *{Array&lt;String&gt;} leaks (optional)*: An array with variable names that should be exported. These variables are accessible via ```myModule.__```
- *{Boolean=true} cache (optional)*: Indicates whether the rewired module should be cached by node so subsequent calls of ```require()``` will return the rewired module. Further calls of ```rewire()``` will always overwrite the cache.
diff --git a/lib/rewire.js b/lib/rewire.js
index 6f1ac7d..6834494 100644
--- a/lib/rewire.js
+++ b/lib/rewire.js
@@ -18,7 +18,7 @@ module.exports = function doRewire(parentModule, filename, mocks, injections, le
nodeRequire,
wrapperExtensions = "";
- function requireTrick(path) {
+ function requireMock(path) {
restoreOriginalWrappers(); // we need to restore the wrappers now so we don't influence other modules
if (mocks && mocks.hasOwnProperty(path)) {
@@ -52,7 +52,7 @@ module.exports = function doRewire(parentModule, filename, mocks, injections, le
Module.wrapper[1] = wrapperExtensions + nodeWrapper1;
// Mocking module.require-function
- testModule.require = requireTrick;
+ testModule.require = requireMock;
// Loading module
testModule.load(testModule.id);