1.0.0 • Published 9 years ago

replace-require-functions v1.0.0

Weekly downloads
32
License
MIT
Repository
github
Last release
9 years ago

replace-require-functions Build Status

Replace the require function for certain modules

Install

$ npm install --save replace-require-functions

Usage

var replaceRequires = require('replace-requires');

// Call it on a string of JS code
replaceRequires('require("foo")', {foo: 'bar'});

// Returns the file, but with the `require` function replaced
bar("foo")

// Call it again
replaceRequires('require("foo/fooz")', {foo: 'bar'});

// Also works on requires with paths; matches the first path segment
bar("foo/fooz")

License

MIT © Ben Drucker