77"use strict" ;
88
99var fs = require ( 'fs' ) ;
10- var path = require ( 'path' ) ;
1110var file = require ( 'file' ) ;
1211var archiver = require ( 'archiver' ) ;
1312var MetaScript = require ( 'MetaScript' ) ;
@@ -60,16 +59,18 @@ function fnameMatch(fpath, inputArray) {
6059
6160// Add a file to the Chrome extension zip
6261function addBuildFile ( platformName , zip , fullPath , zipPath ) {
62+ var fileContents ;
63+
6364 // For the Mozilla extensions in particular, we need to do some preprocessing on JavaScript files
6465 // in order to exclude code specific to other platforms.
6566 if ( javascriptFileRegex . test ( fullPath ) ) {
66- var fileContents = fs . readFileSync ( fullPath ) ;
67+ fileContents = fs . readFileSync ( fullPath ) ;
6768 fileContents = MetaScript . transform ( fileContents , { platform : platformName } ) ;
6869 zip . append ( fileContents , { name : zipPath } ) ;
6970 }
7071 else if ( platformName === CHROME_PLATFORM && manifestJsonFileRegex . test ( fullPath ) ) {
7172 // Remove the Firefox-specific stuff from manifest.json when building for Chrome.
72- var fileContents = fs . readFileSync ( fullPath , { encoding : 'utf8' } ) ;
73+ fileContents = fs . readFileSync ( fullPath , { encoding : 'utf8' } ) ;
7374 fileContents = fileContents . replace ( / , " a p p l i c a t i o n s " : [ ^ { ] * { [ ^ { ] * { [ ^ } ] * } [ ^ } ] * } / m, '' ) ;
7475 zip . append ( fileContents , { name : zipPath } ) ;
7576 }
@@ -96,8 +97,8 @@ function setUpZips() {
9697 }
9798
9899 var chromeZip = new archiver ( 'zip' ) ; // Chrome will reject the zip if there's no compression
99- var firefoxZip = new archiver ( 'zip' , { store : true } ) ;
100- var thunderbirdZip = new archiver ( 'zip' , { store : true } ) ;
100+ var firefoxZip = new archiver ( 'zip' ) ;
101+ var thunderbirdZip = new archiver ( 'zip' ) ; // addons.thunderbird.net rejects the xpi if there's no compression
101102
102103 chromeZip . on ( 'error' , function ( err ) {
103104 console . log ( 'chromeZip error:' , err ) ;
@@ -121,7 +122,7 @@ function setUpZips() {
121122 return {
122123 chrome : chromeZip ,
123124 firefox : firefoxZip ,
124- thunderbird : thunderbirdZip ,
125+ thunderbird : thunderbirdZip
125126 } ;
126127}
127128
0 commit comments