cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [15/28] git commit: adding browserify bundle
Date Thu, 24 Apr 2014 21:14:13 GMT
adding browserify bundle


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

Branch: refs/heads/master
Commit: 8229393c1bdc67b2c3f38e222cc6da029cb45d91
Parents: 62e3e36
Author: Anis Kadri <anis@apache.org>
Authored: Mon Mar 17 14:52:10 2014 -0700
Committer: Anis Kadri <anis@apache.org>
Committed: Fri Apr 11 12:44:04 2014 -0700

----------------------------------------------------------------------
 src/prepare.js | 60 ++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 43 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/8229393c/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 361249d..3b2fbb5 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -19,20 +19,20 @@
 
 /* jshint node:true */
 
-var platform_modules = require('./platforms'),
-    path            = require('path'),
-    config_changes  = require('./util/config-changes'),
-    xml_helpers     = require('./util/xml-helpers'),
-    wp7             = require('./platforms/wp7'),
-    wp8             = require('./platforms/wp8'),
-    windows8        = require('./platforms/windows8'),
-    common          = require('./platforms/common');
-    fs              = require('fs'),
-    shell           = require('shelljs'),
-    util            = require('util'),
-    events          = require('./events'),
-    plugman         = require('../plugman'),
-    et              = require('elementtree');
+var platform_modules   = require('./platforms'),
+    path               = require('path'),
+    config_changes     = require('./util/config-changes'),
+    xml_helpers        = require('./util/xml-helpers'),
+    wp7                = require('./platforms/wp7'),
+    wp8                = require('./platforms/wp8'),
+    windows8           = require('./platforms/windows8'),
+    common             = require('./platforms/common');
+    fs                 = require('fs'),
+    shell              = require('shelljs'),
+    util               = require('util'),
+    plugman            = require('../plugman'),
+    et                 = require('elementtree'),
+    writeLicenseHeader = require('cordova-js/tasks/lib/write-license-header');
 
 // Called on --prepare.
 // Sets up each plugin's Javascript code to be loaded properly.
@@ -116,6 +116,10 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
         }
 
     }
+    
+    /* begin browserify */
+    var libraryRelease = bundle(platform, false, 'N/A');
+    /* end browserify */
 
     platform_json = config_changes.get_platform_json(plugins_dir, platform);
     // This array holds all the metadata for each module and ends up in cordova_plugins.json
@@ -173,12 +177,17 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
             if (module.attrib.name) {
                 moduleName += module.attrib.name;
             } else {
-                var result = module.attrib.src.match(/([^\/]+)\.js/);
-                moduleName += result[1];
+             // var result = module.attrib.src.match(/([^\/]+)\.js/);
+             // moduleName += result[1];
+              moduleName = path.basename(module.attrib.src, '.js');
             }
 
             var fsPath = path.join.apply(path, pathParts);
-            var scriptContent = fs.readFileSync(path.join(pluginDir, fsPath), 'utf-8');
+            var scriptPath = path.join(pluginDir, fsPath);
+
+            libraryRelease.add(fsPath);
+
+            var scriptContent = fs.readFileSync(scriptPath, '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") {
@@ -229,4 +238,21 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir,
www_
         wp_csproj.addSourceFile(path.join('www', 'cordova_plugins.js'));
         wp_csproj.write();
     }
+
+    /* begin browserify */
+    var outReleaseFile = path.join('pkg', 'cordova.' + platform + '.js');
+    var outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+    var commitId = 'N/A';
+    
+    writeLicenseHeader(outReleaseFileStream, platform, commitId);
+     
+    releaseBundle = libraryRelease.bundle();
+
+    releaseBundle.pipe(outReleaseFileStream);
+
+    releaseBundle.on('end', function() {
+      var newtime = new Date().valueOf() - time;
+      plugman.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in
' + newtime + 'ms');
+    });
+    /* end browserify */
 };


Mime
View raw message