You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/04/11 21:47:00 UTC

[44/50] [abbrv] git commit: adding clobbers/merges support

adding clobbers/merges support


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

Branch: refs/heads/browserify
Commit: ef1b980beeb697e9836cba104af065c699cb174c
Parents: 781ec24
Author: Anis Kadri <an...@apache.org>
Authored: Thu Mar 27 19:48:50 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Fri Apr 11 12:45:01 2014 -0700

----------------------------------------------------------------------
 src/prepare.js | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/ef1b980b/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 6fe2fe1..8b770e1 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -185,10 +185,11 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
 
             var fsPath = path.join.apply(path, pathParts);
             var scriptPath = path.join(pluginDir, fsPath);
-
-            libraryRelease.add(scriptPath);
+            var bScriptPath = util.format("%s.%s", scriptPath, 'browserify');
 
             var scriptContent = fs.readFileSync(scriptPath, 'utf-8');
+            fs.writeFileSync(bScriptPath, scriptContent, 'utf-8');
+
             scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) { ' + scriptContent + '\n});\n';
             fs.writeFileSync(path.join(platformPluginsDir, plugin_id, fsPath), scriptContent, 'utf-8');
             if(platform == 'wp7' || platform == 'wp8' || platform == "windows8") {
@@ -208,11 +209,27 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
                         obj.clobbers = [];
                     }
                     obj.clobbers.push(child.attrib.target);
+                    /* FIXME: browserify guettho clobber */
+                    fs.appendFileSync(bScriptPath,
+                      util.format(
+                        "require('cordova/builder').assignOrWrapInDeprecateGetter(window, '%s', module.exports);", 
+                        child.attrib.target
+                      ),
+                      'utf-8');
+                    /* end browserify guettho clobber */
                 } else if (child.tag.toLowerCase() == 'merges') {
                     if (!obj.merges) {
                         obj.merges = [];
                     }
                     obj.merges.push(child.attrib.target);
+                    /* FIXME: browserify guettho clobber */
+                    fs.appendFileSync(bScriptPath,
+                      util.format(
+                        "require('cordova/builder').recursiveMerge(window, '%s', module.exports);", 
+                        child.attrib.target
+                      ),
+                      'utf-8');
+                    /* end browserify guettho clobber */
                 } else if (child.tag.toLowerCase() == 'runs') {
                     obj.runs = true;
                 }
@@ -220,6 +237,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
 
             // Add it to the list of module objects bound for cordova_plugins.json
             moduleObjects.push(obj);
+            libraryRelease.add(bScriptPath);
         });
     });