Skip to content

Commit

Permalink
Hide logs from deleteAll on task: clean client modules into dll (elas…
Browse files Browse the repository at this point in the history
…tic#26884)

* 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.
  • Loading branch information
mistic committed Dec 12, 2018
1 parent 86c9a69 commit 902d305
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
13 changes: 9 additions & 4 deletions src/dev/build/lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
22 changes: 11 additions & 11 deletions src/dev/build/tasks/clean_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
};

Expand All @@ -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);
},
};

Expand Down Expand Up @@ -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);
}
}
},
Expand Down Expand Up @@ -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);
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/dev/build/tasks/nodejs/clean_node_builds_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
};
2 changes: 1 addition & 1 deletion src/dev/build/tasks/nodejs_modules/webpack_dll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/dev/build/tasks/optimize_task.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ export const OptimizeBuildTask = {
});

// clean up temporary node install
await deleteAll(log, [tempNodeInstallDir]);
await deleteAll([tempNodeInstallDir], log);
},
};

0 comments on commit 902d305

Please sign in to comment.