You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2015/07/29 00:38:05 UTC

cordova-lib git commit: CB-9420 Fixes malformed require calls in browserify bundle. This closes #270

Repository: cordova-lib
Updated Branches:
  refs/heads/master b11d0f00b -> fe273fc6f


CB-9420 Fixes malformed require calls in browserify bundle. This closes #270


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/fe273fc6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/fe273fc6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/fe273fc6

Branch: refs/heads/master
Commit: fe273fc6f4519106518ac9fdd168d2350d376329
Parents: b11d0f0
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Tue Jul 28 15:14:56 2015 +0300
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Jul 28 15:37:42 2015 -0700

----------------------------------------------------------------------
 cordova-lib/src/plugman/prepare-browserify.js     | 14 ++++++++++----
 cordova-lib/src/plugman/util/prepare-namespace.js |  5 +++--
 2 files changed, 13 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fe273fc6/cordova-lib/src/plugman/prepare-browserify.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/prepare-browserify.js b/cordova-lib/src/plugman/prepare-browserify.js
index df3ec1e..31dea13 100644
--- a/cordova-lib/src/plugman/prepare-browserify.js
+++ b/cordova-lib/src/plugman/prepare-browserify.js
@@ -217,14 +217,20 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
                 // gets added to the browserify bundle.
                 var namespace;
                 module.clobbers.forEach(function(child) {
-                    namespace = prepareNamespace(child.target, true, scriptPath);
-                    if(cordovaRequires.indexOf(namespace) === -1) {
+                    namespace = prepareNamespace(child.target, true, scriptPath)
+                        // Need to duplicate all backslashes, otherwise paths in
+                        // `require` calls will get corrupted on Windows
+                        .replace(/\\/g, '\\\\');
+                    if(namespace && cordovaRequires.indexOf(namespace) === -1) {
                         cordovaRequires.push(namespace);
                     }
                 });
                 module.merges.forEach(function(child) {
-                    namespace = prepareNamespace(child.target, false, scriptPath);
-                    if(cordovaRequires.indexOf(namespace) === -1) {
+                    namespace = prepareNamespace(child.target, false, scriptPath)
+                        // Need to duplicate all backslashes, otherwise paths in
+                        // `require` calls will get corrupted on Windows
+                        .replace(/\\/g, '\\\\');
+                    if(namespace && cordovaRequires.indexOf(namespace) === -1) {
                         cordovaRequires.push(namespace);
                     }
                 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fe273fc6/cordova-lib/src/plugman/util/prepare-namespace.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/util/prepare-namespace.js b/cordova-lib/src/plugman/util/prepare-namespace.js
index 27dfeeb..f130c05 100644
--- a/cordova-lib/src/plugman/util/prepare-namespace.js
+++ b/cordova-lib/src/plugman/util/prepare-namespace.js
@@ -46,7 +46,7 @@ function prepare_namespace(target, doClobber, scriptPath) {
     var object = props.slice(0, props.length - 1).join('.');
     if(doClobber === true) {
         return util.format(
-                "%s\n;require('cordova/builder').assignOrWrapInDeprecateGetter(%s, '%s', require('%s'));",
+                "%srequire('cordova/builder').assignOrWrapInDeprecateGetter(%s, '%s', require('%s'));",
                 code,
                 object,
                 lastName,
@@ -54,10 +54,11 @@ function prepare_namespace(target, doClobber, scriptPath) {
                 );
     } else if(old !== '') {
         return util.format(
-                "%s\n;require('cordova/builder').recursiveMerge(%s, require('%s'));",
+                "%srequire('cordova/builder').recursiveMerge(%s, require('%s'));",
                 code,
                 old,
                 scriptPath
                 );
     }
+    return "";
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org