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'));
|
2021-05-10 23:16:03 +02:00
|
|
|
const { version } = require('../../package.json');
|
2021-02-04 19:15:23 +01:00
|
|
|
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}/**`),
|
2021-05-10 23:16:03 +02:00
|
|
|
gulpZip(`metamask-${target}-${version}.zip`),
|
2020-03-09 01:55:02 +01:00
|
|
|
gulp.dest('builds'),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
|
|
|
};
|
2020-03-09 01:55:02 +01:00
|
|
|
}
|