[build] Clean extra browsers (#19629)

This commit is contained in:
Jonathan Budzenski 2018-06-01 15:25:39 -05:00 committed by GitHub
parent 99d76fd735
commit 1df4946670
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 0 deletions

View file

@ -23,6 +23,7 @@ import {
BootstrapTask,
BuildPackagesTask,
CleanExtraBinScriptsTask,
CleanExtraBrowsersTask,
CleanExtraFilesFromModulesTask,
CleanPackagesTask,
CleanTypescriptTask,
@ -116,6 +117,7 @@ export async function buildDistributables(options) {
*/
await run(CreateArchivesSourcesTask);
await run(CleanExtraBinScriptsTask);
await run(CleanExtraBrowsersTask);
/**
* package platform-specific builds into archives

View file

@ -84,3 +84,46 @@ export const CleanExtraBinScriptsTask = {
}
}
};
export const CleanExtraBrowsersTask = {
description: 'Cleaning extra browsers from platform-specific builds',
async run(config, log, build) {
const getBrowserPathsForPlatform = (platform) => {
const reportingDir = 'node_modules/x-pack/plugins/reporting';
const phantomDir = '.phantom';
const chromiumDir = '.chromium';
const phantomPath = p => build.resolvePathForPlatform(platform, reportingDir, phantomDir, p);
const chromiumPath = p => build.resolvePathForPlatform(platform, reportingDir, chromiumDir, p);
return platforms => {
const paths = [];
if (platforms.windows) {
paths.push(phantomPath('phantomjs-*-windows.zip'));
paths.push(chromiumPath('chromium-*-win32.zip'));
}
if (platforms.darwin) {
paths.push(phantomPath('phantomjs-*-macosx.zip'));
paths.push(chromiumPath('chromium-*-darwin.zip'));
}
if (platforms.linux) {
paths.push(phantomPath('phantomjs-*-linux-x86_64.tar.bz2'));
paths.push(chromiumPath('chromium-*-linux.zip'));
}
return paths;
};
};
for (const platform of config.getPlatforms()) {
const getBrowserPaths = getBrowserPathsForPlatform(platform);
if (platform.isWindows()) {
await deleteAll(log, getBrowserPaths({ linux: true, darwin: true }));
}
else if (platform.isMac()) {
await deleteAll(log, getBrowserPaths({ linux: true, windows: true }));
} else if (platform.isLinux()) {
await deleteAll(log, getBrowserPaths({ windows: true, darwin: true }));
}
}
}
};