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/27 15:22:30 UTC

[21/34] js commit: adding browserify packager

adding browserify packager


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

Branch: refs/heads/browserify
Commit: dec96272458c8457436c47484275a023e3d7abe5
Parents: 0644971
Author: Anis Kadri <an...@apache.org>
Authored: Mon Feb 3 22:21:01 2014 -0800
Committer: Anis Kadri <an...@apache.org>
Committed: Thu Mar 27 15:20:21 2014 +0100

----------------------------------------------------------------------
 tasks/lib/packager-browserify.js | 59 +++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/dec96272/tasks/lib/packager-browserify.js
----------------------------------------------------------------------
diff --git a/tasks/lib/packager-browserify.js b/tasks/lib/packager-browserify.js
new file mode 100644
index 0000000..299bf89
--- /dev/null
+++ b/tasks/lib/packager-browserify.js
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF
+ * or more contributor license agreements.  See th
+ * distributed with this work for additional infor
+ * regarding copyright ownership.  The ASF license
+ * to you under the Apache License, Version 2.0 (t
+ * "License"); you may not use this file except in
+ * with the License.  You may obtain a copy of the
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to 
+ * software distributed under the License is distr
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+ * KIND, either express or implied.  See the Licen
+ * specific language governing permissions and lim
+ * under the License.
+ */
+var fs              = require('fs');
+var path            = require('path');
+var bundle          = require('./bundle-browserify');
+var computeCommitId = require('./compute-commit-id');
+
+
+module.exports = function generate(platform, useWindowsLineEndings, callback) {
+    computeCommitId(function(commitId) {
+        var outFile, outFileStream;
+        var time = new Date().valueOf();
+
+        var libraryRelease = bundle(platform, false, commitId);
+        // if we are using windows line endings, we will also add the BOM
+        if(useWindowsLineEndings) {
+            libraryRelease = "\ufeff" + libraryRelease.split(/\r?\n/).join("\r\n");
+        }
+        //var libraryDebug   = bundle(platform, true, commitId);
+
+        time = new Date().valueOf() - time;
+        if (!fs.existsSync('pkg')) {
+            fs.mkdirSync('pkg');
+        }
+       // if(!fs.existsSync('pkg/debug')) {
+       //     fs.mkdirSync('pkg/debug');
+       // }
+        //libraryRelease.bundle().pipe(process.stdout);
+
+        outFile = path.join('pkg', 'cordova.' + platform + '.js');
+        outFileStream = fs.createWriteStream(outFile);
+        libraryRelease.bundle().pipe(outFileStream);
+
+        libraryRelease.bundle().on('end', function() {
+          console.log('generated cordova.' + platform + '.js @ ' + commitId + ' in ' + time + 'ms');
+          callback();
+        });
+
+       // outFile = path.join('pkg', 'debug', 'cordova.' + platform + '-debug.js');
+       // outFileStream = fs.createWriteStream(outFile);
+       // libraryDebug.bundle().pipe(outFileStream);
+    });
+}