blob: 2c800917a0a254cdb28839557fb15db8f11b7ca7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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;
|