2021-02-04 19:15:23 +01:00
|
|
|
const { promises: fs } = require('fs');
|
|
|
|
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');
|
2020-03-09 01:55:02 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
module.exports = createEtcTasks;
|
2020-03-09 01:55:02 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function createEtcTasks({ browserPlatforms, livereload }) {
|
|
|
|
const clean = createTask('clean', async function clean() {
|
2021-02-04 19:15:23 +01:00
|
|
|
await del(['./dist/*']);
|
2020-11-03 00:41:28 +01:00
|
|
|
await Promise.all(
|
|
|
|
browserPlatforms.map(async (platform) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
await fs.mkdir(`./dist/${platform}`, { recursive: true });
|
2020-11-03 00:41:28 +01:00
|
|
|
}),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
});
|
2020-03-09 01:55:02 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
const reload = createTask('reload', function devReload() {
|
2021-02-04 19:15:23 +01:00
|
|
|
livereload.listen({ port: 35729 });
|
|
|
|
});
|
2020-03-09 01:55:02 +01:00
|
|
|
|
|
|
|
// zip tasks for distribution
|
2020-11-03 00:41:28 +01:00
|
|
|
const zip = createTask(
|
|
|
|
'zip',
|
|
|
|
composeParallel(
|
|
|
|
...browserPlatforms.map((platform) => createZipTask(platform)),
|
|
|
|
),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
2020-03-09 01:55:02 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
return { clean, reload, zip };
|
2020-03-09 01:55:02 +01:00
|
|
|
}
|
|
|
|
|
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'),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|
2020-03-09 01:55:02 +01:00
|
|
|
}
|