7
7
"use strict" ;
8
8
9
9
var fs = require ( 'fs' ) ;
10
- var path = require ( 'path' ) ;
11
10
var file = require ( 'file' ) ;
12
11
var archiver = require ( 'archiver' ) ;
13
12
var MetaScript = require ( 'MetaScript' ) ;
@@ -60,16 +59,18 @@ function fnameMatch(fpath, inputArray) {
60
59
61
60
// Add a file to the Chrome extension zip
62
61
function addBuildFile ( platformName , zip , fullPath , zipPath ) {
62
+ var fileContents ;
63
+
63
64
// For the Mozilla extensions in particular, we need to do some preprocessing on JavaScript files
64
65
// in order to exclude code specific to other platforms.
65
66
if ( javascriptFileRegex . test ( fullPath ) ) {
66
- var fileContents = fs . readFileSync ( fullPath ) ;
67
+ fileContents = fs . readFileSync ( fullPath ) ;
67
68
fileContents = MetaScript . transform ( fileContents , { platform : platformName } ) ;
68
69
zip . append ( fileContents , { name : zipPath } ) ;
69
70
}
70
71
else if ( platformName === CHROME_PLATFORM && manifestJsonFileRegex . test ( fullPath ) ) {
71
72
// 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' } ) ;
73
74
fileContents = fileContents . replace ( / , " a p p l i c a t i o n s " : [ ^ { ] * { [ ^ { ] * { [ ^ } ] * } [ ^ } ] * } / m, '' ) ;
74
75
zip . append ( fileContents , { name : zipPath } ) ;
75
76
}
@@ -96,8 +97,8 @@ function setUpZips() {
96
97
}
97
98
98
99
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
101
102
102
103
chromeZip . on ( 'error' , function ( err ) {
103
104
console . log ( 'chromeZip error:' , err ) ;
@@ -121,7 +122,7 @@ function setUpZips() {
121
122
return {
122
123
chrome : chromeZip ,
123
124
firefox : firefoxZip ,
124
- thunderbird : thunderbirdZip ,
125
+ thunderbird : thunderbirdZip
125
126
} ;
126
127
}
127
128
0 commit comments