-
Notifications
You must be signed in to change notification settings - Fork 17
/
Build.js
43 lines (38 loc) · 1.29 KB
/
Build.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
'use strict'
const fs = require('fs')
const JSZip = require('jszip')
const CODE = [
'browser-polyfill.min.js',
'common.js',
'background.js',
'options.html', 'options.css', 'options.js',
'popup.html', 'popup.css', 'popup.js',
'icon.svg', 'icon48.png', 'gear.svg', 'info.svg'
]
function addCode (zip) {
for (const name of CODE) {
zip.file(name, fs.readFileSync(name))
}
}
const fxzip = new JSZip()
addCode(fxzip)
fxzip.file('manifest.json', fs.readFileSync('manifest.json'))
fxzip.generateNodeStream({type: 'nodebuffer', streamFiles: true, compression: 'DEFLATE'})
.pipe(fs.createWriteStream('transmitter-firefox.zip'))
const crzip = new JSZip()
addCode(crzip)
crzip.file('icon16.png', fs.readFileSync('icon16.png'))
crzip.file('icon32.png', fs.readFileSync('icon32.png'))
crzip.file('icon128.png', fs.readFileSync('icon128.png'))
const crmanifest = require('./manifest.json')
delete crmanifest['applications']
delete crmanifest['protocol_handlers']
crmanifest.icons = crmanifest.browser_action.default_icon = {
'128': 'icon128.png',
'48': 'icon48.png',
'32': 'icon32.png',
'16': 'icon16.png',
}
crzip.file('manifest.json', JSON.stringify(crmanifest))
crzip.generateNodeStream({type: 'nodebuffer', streamFiles: true, compression: 'DEFLATE'})
.pipe(fs.createWriteStream('transmitter-chropera.zip'))