diff options
author | Johannes <johannes.ewald@roomieplanet.de> | 2012-08-18 18:34:13 +0400 |
---|---|---|
committer | Johannes <johannes.ewald@roomieplanet.de> | 2012-08-18 18:34:13 +0400 |
commit | c5d8fab07f0edc568e45e0747f863afd5876abc2 (patch) | |
tree | ab57b94703d16087fbb6c81e4bdb5d1ae6217d19 /lib/bundlers/getRewireRequires.js | |
parent | 657b9e84018014d15916c86274b8ee35b9386627 (diff) |
- Introduced webpack bundler for rewire (work in progress, some tests are not running)
Diffstat (limited to 'lib/bundlers/getRewireRequires.js')
-rw-r--r-- | lib/bundlers/getRewireRequires.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/bundlers/getRewireRequires.js b/lib/bundlers/getRewireRequires.js new file mode 100644 index 0000000..2c80091 --- /dev/null +++ b/lib/bundlers/getRewireRequires.js @@ -0,0 +1,24 @@ +var getRewireRegExp = require("./getRewireRegExp.js"); + +/** + * Searches for rewire(); statements and returns all strings that are between the brackets. + * + * @param {!String} src + * @return {Array} + */ +function getRewireRequires(src) { + var result = [], + regExp = getRewireRegExp(), + match; + + src = " " + src; // ensure that rewire() is not at index 0 otherwise the regexp won't work in this case + match = regExp.exec(src); + while (match !== null) { + result.push(match[2]); + match = regExp.exec(src); + } + + return result; +} + +module.exports = getRewireRequires;
\ No newline at end of file |