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/03/29 21:16:58 UTC

git commit: creating a transform for org.apache.cordova.* modules

Repository: cordova-plugman
Updated Branches:
  refs/heads/browserify cd13a49a7 -> 4146171ff


creating a transform for org.apache.cordova.* modules


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

Branch: refs/heads/browserify
Commit: 4146171ff53300a058df198dbfbe436ae820ea76
Parents: cd13a49
Author: Anis Kadri <an...@apache.org>
Authored: Sat Mar 29 21:16:47 2014 +0100
Committer: Anis Kadri <an...@apache.org>
Committed: Sat Mar 29 21:16:47 2014 +0100

----------------------------------------------------------------------
 src/prepare.js | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/4146171f/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 5c6b694..d8fc634 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -32,7 +32,8 @@ var platform_modules   = require('./platforms'),
     util               = require('util'),
     plugman            = require('../plugman'),
     et                 = require('elementtree'),
-    bundle             = require('cordova-js/tasks/lib/bundle-browserify');
+    bundle             = require('cordova-js/tasks/lib/bundle-browserify'),
+    requireTr          = require('cordova-js/tasks/lib/require-tr'),
     writeLicenseHeader = require('cordova-js/tasks/lib/write-license-header');
 
 // Called on --prepare.
@@ -121,6 +122,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
     }
     
     /* begin browserify */
+    requireTr.platform = platform;
     var libraryRelease = bundle(platform, false, 'N/A');
     /* end browserify */
 
@@ -187,7 +189,11 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
 
             var fsPath = path.join.apply(path, pathParts);
             var scriptPath = path.join(pluginDir, fsPath);
+
+            /* begin browserify */
             var bScriptPath = util.format("%s.%s", scriptPath, 'browserify');
+            requireTr.addModule({symbol: new RegExp(moduleName), path: bScriptPath});
+            /* end browserify */
 
             var scriptContent = fs.readFileSync(scriptPath, 'utf-8');
             fs.writeFileSync(bScriptPath, scriptContent, 'utf-8');
@@ -239,7 +245,10 @@ 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);
+            /* begin browserify */
+            libraryRelease.transform(requireTr.transform);
             libraryRelease.add(bScriptPath);
+            /* end browserify */
         });
     });
 
@@ -275,6 +284,7 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
     outReleaseFileStream.on('finish', function() {
       var newtime = new Date().valueOf() - time;
       plugman.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
+      // TODO clean up all the *.browserify files
     });
 
     outReleaseFileStream.on('error', function(err) {
@@ -282,4 +292,5 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
       console.log('error while generating cordova_b.js');
       plugman.emit('verbose', 'error while generating cordova.js');
     });
+    /* end browserify */
 };