-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (24 loc) · 993 Bytes
/
index.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
const fs = require('fs')
const fse = require('fs-extra')
const watch = require('node-watch')
function build () {
fse.copySync('./extension', './build/chrome', { overwrite: true })
fse.copySync('./extension', './build/firefox', { overwrite: true })
delete require.cache[require.resolve('./manifest')]
const chromeManifest = require('./manifest')(false)
const ffManifest = require('./manifest')(true)
fs.writeFileSync('./build/chrome/manifest.json', JSON.stringify(chromeManifest))
fs.writeFileSync('./build/firefox/manifest.json', JSON.stringify(ffManifest))
}
build()
console.log('\x1b[32mBuild successful\x1b[0m')
if (process.argv.indexOf('--watch') > -1) {
watch('extension', { recursive: true }, function (evt, name) {
console.log('\x1b[36mRebuilding due to changes\x1b[0m', `(${name})`)
build()
})
watch('manifest.js', { recursive: true }, function (evt, name) {
console.log('\x1b[36mRebuilding due to changes\x1b[0m', `(${name})`)
build()
})
}