1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 12:29:06 +01:00
metamask-extension/development/build/etc.js
Mark Stacey 3f577700c6
Replace isBeta with buildType (#12231)
This is a refactor to replace the `isBeta` boolean with `buildType`
throughout the build system. This will allow us to modify the behaviour
of each step of the build process for Flask as well.

This should result in no functional changes.
2021-09-28 13:43:26 -02:30

61 lines
1.5 KiB
JavaScript

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 { version } = require('../../package.json');
const { createTask, composeParallel } = require('./task');
const { BuildTypes } = require('./utils');
module.exports = createEtcTasks;
function createEtcTasks({
betaVersionsMap,
browserPlatforms,
buildType,
livereload,
}) {
const clean = createTask('clean', async function clean() {
await del(['./dist/*']);
await Promise.all(
browserPlatforms.map(async (platform) => {
await fs.mkdir(`./dist/${platform}`, { recursive: true });
}),
);
});
const reload = createTask('reload', function devReload() {
livereload.listen({ port: 35729 });
});
// zip tasks for distribution
const zip = createTask(
'zip',
composeParallel(
...browserPlatforms.map((platform) =>
createZipTask(
platform,
buildType === BuildTypes.beta ? betaVersionsMap[platform] : undefined,
),
),
),
);
return { clean, reload, zip };
}
function createZipTask(platform, betaVersion) {
return async () => {
const path = betaVersion
? `metamask-BETA-${platform}-${betaVersion}`
: `metamask-${platform}-${version}`;
await pump(
gulp.src(`dist/${platform}/**`),
gulpZip(`${path}.zip`),
gulp.dest('builds'),
);
};
}