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
|
|
|
|
2021-09-08 22:08:23 +02:00
|
|
|
function createEtcTasks({
|
|
|
|
browserPlatforms,
|
|
|
|
livereload,
|
|
|
|
isBeta,
|
|
|
|
betaVersionsMap,
|
|
|
|
}) {
|
2020-11-03 00:41:28 +01:00
|
|
|
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(
|
2021-09-08 22:08:23 +02:00
|
|
|
...browserPlatforms.map((platform) =>
|
|
|
|
createZipTask(platform, isBeta ? betaVersionsMap[platform] : undefined),
|
|
|
|
),
|
2020-11-03 00:41:28 +01:00
|
|
|
),
|
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
|
|
|
}
|
|
|
|
|
2021-09-08 22:08:23 +02:00
|
|
|
function createZipTask(platform, betaVersion) {
|
2020-03-09 01:55:02 +01:00
|
|
|
return async () => {
|
2021-09-08 22:08:23 +02:00
|
|
|
const path = betaVersion
|
|
|
|
? `metamask-BETA-${platform}-${betaVersion}`
|
|
|
|
: `metamask-${platform}-${version}`;
|
2020-03-09 01:55:02 +01:00
|
|
|
await pump(
|
2021-09-08 22:08:23 +02:00
|
|
|
gulp.src(`dist/${platform}/**`),
|
|
|
|
gulpZip(`${path}.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
|
|
|
}
|