deps-regex
Regular expression for matching javascript require statements.
This is pretty fragile and created for perf reasons where using a real parser would be overkill.
Install
Install with npm
$ npm i deps-regex --save
Usage
var DepsRegex = require('deps-regex');
var re = new DepsRegex({
matchInternal: true,
matchES6: true,
matchCoffeescript: true
})
re.getDependencies('var foo = require(\'bar\');');
//=>
// [ 'bar']
Known false positives
module.exports = 'require("false-positive");';
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
License
Released under the MIT license.