summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/lib/optional.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/lib/optional.js')
-rw-r--r--deps/npm/node_modules/request/lib/optional.js14
1 files changed, 11 insertions, 3 deletions
diff --git a/deps/npm/node_modules/request/lib/optional.js b/deps/npm/node_modules/request/lib/optional.js
index 0c4fe8533f..af0cc15f8c 100644
--- a/deps/npm/node_modules/request/lib/optional.js
+++ b/deps/npm/node_modules/request/lib/optional.js
@@ -1,5 +1,13 @@
-module.exports = function(module) {
+module.exports = function(moduleName) {
try {
- return require(module);
- } catch (e) {}
+ return module.parent.require(moduleName);
+ } catch (e) {
+ // This could mean that we are in a browser context.
+ // Add another try catch like it used to be, for backwards compability
+ // and browserify reasons.
+ try {
+ return require(moduleName);
+ }
+ catch (e) {}
+ }
};