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:
authorjeroenvalcke <valcke_jeroen@hotmail.com>2017-11-08 13:19:24 +0300
committerjeroenvalcke <valcke_jeroen@hotmail.com>2017-11-08 13:19:24 +0300
commitc0e1b87c2a40eeb5046ed55f41f89755f1a51924 (patch)
tree867b90bba4bab2b76ab7e2a85d7eb493ddd82f97
parentd1ad67aaa899b40d7fcf24df19d7f0a3fb8be70a (diff)
Remove opts and only use old load functionality for coffee scripts
-rw-r--r--lib/index.js4
-rw-r--r--lib/moduleEnv.js2
-rw-r--r--lib/rewire.js15
3 files changed, 9 insertions, 12 deletions
diff --git a/lib/index.js b/lib/index.js
index 765de10..0edcd2c 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -7,8 +7,8 @@ var rewireModule = require("./rewire.js");
* @param {!String} filename Path to the module that shall be rewired. Use it exactly like require().
* @return {*} the rewired module
*/
-function rewire(filename, opts) {
- return rewireModule(module.parent, filename, opts);
+function rewire(filename) {
+ return rewireModule(module.parent, filename);
}
module.exports = rewire;
diff --git a/lib/moduleEnv.js b/lib/moduleEnv.js
index 29c407c..dd003d7 100644
--- a/lib/moduleEnv.js
+++ b/lib/moduleEnv.js
@@ -12,7 +12,7 @@ var moduleWrapper0 = Module.wrapper[0],
nodeRequire,
currentModule;
-function load(targetModule, isTransform) {
+function load(targetModule) {
nodeRequire = targetModule.require;
targetModule.require = requireProxy;
currentModule = targetModule;
diff --git a/lib/rewire.js b/lib/rewire.js
index 1d240d4..536929d 100644
--- a/lib/rewire.js
+++ b/lib/rewire.js
@@ -9,15 +9,11 @@ var Module = require("module"),
/**
* Does actual rewiring the module. For further documentation @see index.js
*/
-function internalRewire(parentModulePath, targetPath, opts) {
+function internalRewire(parentModulePath, targetPath) {
var targetModule,
prelude,
appendix,
- src,
- isTransform;
-
- opts = typeof opts === "object" ? opts : {};
- isTransform = !!opts.convertConst;
+ src;
// Checking params
if (typeof targetPath !== "string") {
@@ -60,12 +56,13 @@ function internalRewire(parentModulePath, targetPath, opts) {
moduleEnv.inject(prelude, appendix);
- if(isTransform) {
- moduleEnv.compile(targetModule, src, targetPath);
- } else {
+ if (targetPath.match(/\.coffee$/)) {
moduleEnv.load(targetModule);
+ } else {
+ moduleEnv.compile(targetModule, src, targetPath);
}
+
return targetModule.exports;
}