Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite633022

Browse files
committed
added documentation
1 parent3cef656 commite633022

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ rewire("./myModuleA.js", null, null, null, false) !== require("./myModuleA.js");
101101

102102
-*{!String} filename*: Path to the module that shall be rewired. Use it exactly like require().
103103
-*{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}```.
104-
-*{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()```.
104+
-*{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()```.
105105
-*{Array<String>} leaks (optional)*: An array with variable names that should be exported. These variables are accessible via```myModule.__```
106106
-*{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.
107107

‎lib/rewire.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = function doRewire(parentModule, filename, mocks, injections, le
1818
nodeRequire,
1919
wrapperExtensions="";
2020

21-
functionrequireTrick(path){
21+
functionrequireMock(path){
2222
restoreOriginalWrappers();// we need to restore the wrappers now so we don't influence other modules
2323

2424
if(mocks&&mocks.hasOwnProperty(path)){
@@ -52,7 +52,7 @@ module.exports = function doRewire(parentModule, filename, mocks, injections, le
5252
Module.wrapper[1]=wrapperExtensions+nodeWrapper1;
5353

5454
// Mocking module.require-function
55-
testModule.require=requireTrick;
55+
testModule.require=requireMock;
5656
// Loading module
5757
testModule.load(testModule.id);
5858

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp