2020-08-18 21:18:25 +02:00
|
|
|
const { promises: fs } = require('fs')
|
2020-03-09 01:55:02 +01:00
|
|
|
const gulp = require('gulp')
|
|
|
|
const gulpZip = require('gulp-zip')
|
|
|
|
const del = require('del')
|
|
|
|
const pify = require('pify')
|
|
|
|
const pump = pify(require('pump'))
|
|
|
|
const baseManifest = require('../../app/manifest/_base.json')
|
|
|
|
const { createTask, composeParallel } = require('./task')
|
|
|
|
|
|
|
|
module.exports = createEtcTasks
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function createEtcTasks({ browserPlatforms, livereload }) {
|
|
|
|
const clean = createTask('clean', async function clean() {
|
2020-03-09 01:55:02 +01:00
|
|
|
await del(['./dist/*'])
|
2020-11-03 00:41:28 +01:00
|
|
|
await Promise.all(
|
|
|
|
browserPlatforms.map(async (platform) => {
|
|
|
|
await fs.mkdir(`./dist/${platform}`, { recursive: true })
|
|
|
|
}),
|
|
|
|
)
|
2020-03-09 01:55:02 +01:00
|
|
|
})
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const reload = createTask('reload', function devReload() {
|
2020-03-09 01:55:02 +01:00
|
|
|
livereload.listen({ port: 35729 })
|
|
|
|
})
|
|
|
|
|
|
|
|
// zip tasks for distribution
|
2020-11-03 00:41:28 +01:00
|
|
|
const zip = createTask(
|
|
|
|
'zip',
|
|
|
|
composeParallel(
|
|
|
|
...browserPlatforms.map((platform) => createZipTask(platform)),
|
|
|
|
),
|
|
|
|
)
|
2020-03-09 01:55:02 +01:00
|
|
|
|
|
|
|
return { clean, reload, zip }
|
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function createZipTask(target) {
|
2020-03-09 01:55:02 +01:00
|
|
|
return async () => {
|
|
|
|
await pump(
|
|
|
|
gulp.src(`dist/${target}/**`),
|
|
|
|
gulpZip(`metamask-${target}-${baseManifest.version}.zip`),
|
|
|
|
gulp.dest('builds'),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|