-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
Ref #56
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ assert.equal(foo.basenameAllCaps('/a/b/file.txt'), 'FILE.TXT'); | |
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)* | ||
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)* | ||
|
||
- [Usage](#usage) | ||
- [API](#api) | ||
|
@@ -70,6 +70,7 @@ assert.equal(foo.basenameAllCaps('/a/b/file.txt'), 'FILE.TXT'); | |
- [Globally override require during module initialization](#globally-override-require-during-module-initialization) | ||
- [Why is proxyquire messing with my `require` cache?](#why-is-proxyquire-messing-with-my-require-cache) | ||
- [Globally override require during module runtime](#globally-override-require-during-module-runtime) | ||
- [Modules That Export Functions](#modules-that-export-functions) | ||
- [Backwards Compatibility for proxyquire v0.3.x](#backwards-compatibility-for-proxyquire-v03x) | ||
- [Examples](#examples) | ||
- [More Examples](#more-examples) | ||
|
@@ -357,6 +358,26 @@ every time the module is requested via `require` at runtime as no module will ev | |
This can cause subtle bugs so if you can guarantee that your modules will not vary their `require` behaviour at runtime, | ||
use `@global` instead. | ||
|
||
## Modules That Export Functions | ||
|
||
Even if you want to override a module that exports a function directly, you can still set special properties like `@global`. You can use a named function or assign your stub function to a variable to add properties: | ||
|
||
```js | ||
foo['@global'] = true; | ||
function foo () {} | ||
proxyquire('./bar', { | ||
foo: foo | ||
}); | ||
``` | ||
|
||
```js | ||
var foo = function () {}; | ||
foo['@global'] = true; | ||
proxyquire('./bar', { | ||
foo: foo | ||
}); | ||
``` | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bendrucker
Author
Collaborator
|
||
|
||
# Backwards Compatibility for proxyquire v0.3.x | ||
|
||
Compatibility mode with proxyquire v0.3.x **has been removed**. | ||
|
2 comments
on commit 74365bf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for very minor things it'd be easier to work off the master branch and discuss changes via a PR.
That way we can get it perfect before merging into master.
Also it's easier to see all the comments that way instead of spread over different commits.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
Am I missing something or are these examples identical except for assignment vs. declaration?
I think it'd be very useful to show the case of someone
require
ing a stub from a module and then adding the flag.We could change the heading to Configuring proxyquire by setting stub properties.
Then show the first function example and something similar to: