@ -482,9 +482,8 @@ target.bundle = function(args) {
@@ -482,9 +482,8 @@ target.bundle = function(args) {
cd ( ROOT _DIR ) ;
echo ( ) ;
echo ( '### Bundling files into ' + BUILD _TARGET ) ;
var reg = /\n\/\* -\*- Mode(.|\n)*?Mozilla Foundation(.|\n)*?'use strict';/g ;
function bundle ( filename , dir , SRC _FILES , EXT _SRC _FILES ) {
function bundle ( filename , outfilename , SRC _FILES , EXT _SRC _FILES ) {
for ( var i = 0 , length = excludes . length ; i < length ; ++ i ) {
var exclude = excludes [ i ] ;
var index = SRC _FILES . indexOf ( exclude ) ;
@ -500,15 +499,17 @@ target.bundle = function(args) {
@@ -500,15 +499,17 @@ target.bundle = function(args) {
crlfchecker . checkIfCrlfIsPresent ( SRC _FILES ) ;
// Strip out all the vim/license headers.
bundleContent = bundleContent . replace ( reg , '' ) ;
// Prepend a newline because stripCommentHeaders only strips comments that
// follow a line feed. The file where bundleContent is inserted already
// contains a license header, so the header of bundleContent can be removed.
bundleContent = stripCommentHeaders ( '\n' + bundleContent ) ;
// Append external files last since we don't want to modify them.
bundleContent += cat ( EXT _SRC _FILES ) ;
// This just preprocesses the empty pdf.js file, we don't actually want to
// preprocess everything yet since other build targets use this file.
builder . preprocess ( filename , dir , builder . merge ( defines ,
builder . preprocess ( filename , outfilename , builder . merge ( defines ,
{ BUNDLE : bundleContent ,
BUNDLE _VERSION : bundleVersion ,
BUNDLE _BUILD : bundleBuild } ) ) ;
@ -600,12 +601,21 @@ target.singlefile = function() {
@@ -600,12 +601,21 @@ target.singlefile = function() {
} ;
function stripCommentHeaders ( content , filename ) {
// Strip out all the vim/license headers.
var notEndOfComment = '(?:[^*]|\\*(?!/))+' ;
var reg = new RegExp (
'\n/\\* -\\*- Mode' + notEndOfComment + '\\*/\\s*' +
'(?:/\\*' + notEndOfComment + '\\*/\\s*|//(?!#).*\n\\s*)+' +
'\'use strict\';' , 'g' ) ;
content = content . replace ( reg , '' ) ;
return content ;
}
function cleanupJSSource ( file ) {
var content = cat ( file ) ;
// Strip out all the vim/license headers.
var reg = /\n\/\* -\*- Mode(.|\n)*?Mozilla Foundation(.|\n)*?'use strict';/g ;
content = content . replace ( reg , '' ) ;
content = stripCommentHeaders ( content , file ) ;
content . to ( file ) ;
}