thlorenz/proxyquire — pull request #32 by achingbrain (2014-05-10 09:34:07+00:00)
Title: Adds global overrides, tests, removes compat mode and revs version number

This pull request adds the ability to (and tests for) overriding require globally:

```javascript
var stubs = {
'child_process': {
exec: function(file, cb) {
cb(null, null, 'success');
},
'@global': true
}
};
```

The above covers this sort of use case:

```javascript
// foo.js - the module being proxyquired
var bar = require('bar');

module.exports = function(path, cb) {
return bar(path, cb);
}

// bar.js
var child_process = require('child_process'); // <- will be overridden

module.exports = function(path, cb) {
child_process.exec(path, cb);
}
```

If dependencies are `require`d at run time, you can also override them with `@runtimeGlobal`:

```javascript
var stubs = {
'child_process': {
exec: function(file, cb) {
cb(null, null, 'success');
},
'@runtimeGlobal': true
}
};
```

```javascript
// bar.js
module.exports = function(path, cb) {
var child_process = require('child_process'); // <- will be overridden
child_process.exec(path, cb);
}
```

This is a sort of last resort option because the a modules require behaviour becomes hard to predict so we don't cache anything at all. This can lead to odd bugs which is why I split the functionality out into `@runtimeGlobal`.

The pull request also:

1. Makes `npm test` print unit test coverage
2. Removes compat mode
3. Updates dependencies to the latest versions
4. Updates the version number to 1.0

I had to do quite a lot of refactoring so touched a lot of files for which I apologise - happy to discuss and make any amends.