require-modify

Modify the source of a required module

npm install require-modify
2 downloads in the last week
4 downloads in the last month

require-modify Build Status

Modify the source of a required module

Install

Install with npm

npm install --save require-modify

Example

// greet.js
module.exports = function () {
    console.log('hello');
};
var requireModify = require('require-modify');

var greet = requireModify('./greet', function (source) {
    return source.replace('hello', 'yo');
});

greet();
//=> yo

API

requireModify(moduleId, callback)

moduleId

Required
Type: String

Same as you would use in require().

callback(source)

Type: Function

Callback where you can modify the source and return the new one.

License

MIT © Sindre Sorhus

npm loves you