Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/rewire.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/browserify/getRewireRequires.js')
-rw-r--r--lib/browserify/getRewireRequires.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/browserify/getRewireRequires.js b/lib/browserify/getRewireRequires.js
new file mode 100644
index 0000000..c8b0f01
--- /dev/null
+++ b/lib/browserify/getRewireRequires.js
@@ -0,0 +1,16 @@
+function getRewireRequires(src) {
+ var result = [],
+ regExp = /[^a-zA-Z0-9_]rewire\(["'](.+?)["']\)/g,
+ 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[1]);
+ match = regExp.exec(src);
+ }
+
+ return result;
+}
+
+module.exports = getRewireRequires; \ No newline at end of file