incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject js commit: [common] [build] added a stripheader helper function for builder, stripping out the license headers from each individual module.
Date Mon, 17 Sep 2012 22:31:18 GMT
Updated Branches:
  refs/heads/master 68e3e2749 -> 60666b000


[common] [build] added a stripheader helper function for builder, stripping out the license
headers from each individual module.


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

Branch: refs/heads/master
Commit: 60666b000b2afd94a15d8ad537b883483e96e24c
Parents: 68e3e27
Author: Fil Maj <maj.fil@gmail.com>
Authored: Mon Sep 17 15:30:52 2012 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Mon Sep 17 15:30:52 2012 -0700

----------------------------------------------------------------------
 build/packager.js |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/60666b00/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index 52843fe..6c1b846 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -178,22 +178,22 @@ function collectFiles(dir, id) {
 //------------------------------------------------------------------------------
 function writeScript(oFile, fileName, debug) {
     var contents = getContents(fileName, 'utf8')
+
+    contents = stripHeader(contents)
     
     writeContents(oFile, fileName, contents, debug)    
 }
 
 //------------------------------------------------------------------------------
 function writeModule(oFile, fileName, moduleId, debug) {
-    var contents = '\n' + getContents(fileName, 'utf8') + '\n'
+    var contents = getContents(fileName, 'utf8')
+
+    contents = '\n' + stripHeader(contents) + '\n'
 
 	// Windows fix, '\' is an escape, but defining requires '/' -jm
     moduleId = path.join('cordova', moduleId).split("\\").join("/");
-	
-	
     
     var signature = 'function(require, exports, module)';
-	
-	
     
     contents = 'define("' + moduleId + '", ' + signature + ' {' + contents + '});\n'
 
@@ -249,3 +249,16 @@ function copyProps(target, source) {
     
     return target
 }
+//-----------------------------------------------------------------------------
+// Strips the license header. Basically only the first multi-line comment up to to the closing
*/
+function stripHeader(contents) {
+    var ls = contents.split('\n');
+    while (ls[0]) {
+        if (ls[0].match(/^\s*\/\*/) || ls[0].match(/^\s*\*/)) ls.shift();
+        else if (ls[0].match(/^\s*\*\//)) {
+            ls.shift();
+            break;
+        }
+    }
+    return ls.join('\n');
+}


Mime
View raw message