Hide logs from deleteAll on task: clean client modules into dll (#26884) (#27011)

* refact(NA): deleteAll function in order to allow it to not log anything out.

* fix(NA): add missing no op debug and verbose functions.

* refact(NA): wrap log calls into if calls.
This commit is contained in:
Tiago Costa 2018-12-12 03:40:49 +00:00 committed by GitHub
parent 86c9a69c16
commit fd0a9213f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 19 deletions

View file

@ -95,12 +95,14 @@ export async function copy(source, destination) {
await chmodAsync(destination, stat.mode);
}
export async function deleteAll(log, patterns) {
export async function deleteAll(patterns, log) {
if (!Array.isArray(patterns)) {
throw new TypeError('Expected patterns to be an array');
}
log.debug('Deleting patterns:', longInspect(patterns));
if (log) {
log.debug('Deleting patterns:', longInspect(patterns));
}
for (const pattern of patterns) {
assertAbsolute(pattern.startsWith('!') ? pattern.slice(1) : pattern);
@ -109,8 +111,11 @@ export async function deleteAll(log, patterns) {
const files = await del(patterns, {
concurrency: 4
});
log.debug('Deleted %d files/directories', files.length);
log.verbose('Deleted:', longInspect(files));
if (log) {
log.debug('Deleted %d files/directories', files.length);
log.verbose('Deleted:', longInspect(files));
}
}
export async function deleteEmptyFolders(log, rootFolderPath, foldersToKeep) {

View file

@ -26,10 +26,10 @@ export const CleanTask = {
description: 'Cleaning artifacts from previous builds',
async run(config, log) {
await deleteAll(log, [
await deleteAll([
config.resolveFromRepo('build'),
config.resolveFromRepo('target'),
]);
], log);
},
};
@ -38,11 +38,11 @@ export const CleanPackagesTask = {
'Cleaning source for packages that are now installed in node_modules',
async run(config, log, build) {
await deleteAll(log, [
await deleteAll([
build.resolvePath('packages'),
build.resolvePath('x-pack'),
build.resolvePath('yarn.lock'),
]);
], log);
},
};
@ -176,14 +176,14 @@ export const CleanExtraBinScriptsTask = {
async run(config, log, build) {
for (const platform of config.getNodePlatforms()) {
if (platform.isWindows()) {
await deleteAll(log, [
await deleteAll([
build.resolvePathForPlatform(platform, 'bin', '*'),
`!${build.resolvePathForPlatform(platform, 'bin', '*.bat')}`,
]);
], log);
} else {
await deleteAll(log, [
await deleteAll([
build.resolvePathForPlatform(platform, 'bin', '*.bat'),
]);
], log);
}
}
},
@ -224,11 +224,11 @@ export const CleanExtraBrowsersTask = {
for (const platform of config.getNodePlatforms()) {
const getBrowserPaths = getBrowserPathsForPlatform(platform);
if (platform.isWindows()) {
await deleteAll(log, getBrowserPaths({ linux: true, darwin: true }));
await deleteAll(getBrowserPaths({ linux: true, darwin: true }), log);
} else if (platform.isMac()) {
await deleteAll(log, getBrowserPaths({ linux: true, windows: true }));
await deleteAll(getBrowserPaths({ linux: true, windows: true }), log);
} else if (platform.isLinux()) {
await deleteAll(log, getBrowserPaths({ windows: true, darwin: true }));
await deleteAll(getBrowserPaths({ windows: true, darwin: true }), log);
}
}
},

View file

@ -25,11 +25,11 @@ export const CleanNodeBuildsTask = {
async run(config, log, build) {
for (const platform of config.getNodePlatforms()) {
await deleteAll(log, [
await deleteAll([
build.resolvePathForPlatform(platform, 'node/lib/node_modules'),
build.resolvePathForPlatform(platform, 'node/bin/npm'),
build.resolvePathForPlatform(platform, 'node/bin/npx'),
]);
], log);
}
},
};

View file

@ -83,7 +83,7 @@ export async function cleanDllModuleFromEntryPath(logger, entryPath) {
`!${moduleDir}/**/*.+(gif|ico|jpeg|jpg|tiff|tif|svg|png|webp)`,
`!${modulePkgPath}`,
]);
await deleteAll(logger, deletePatterns);
await deleteAll(deletePatterns);
// Mark this module as cleaned
modulePkg.cleaned = true;

View file

@ -52,6 +52,6 @@ export const OptimizeBuildTask = {
});
// clean up temporary node install
await deleteAll(log, [tempNodeInstallDir]);
await deleteAll([tempNodeInstallDir], log);
},
};