diff --git a/src/dev/build/lib/fs.js b/src/dev/build/lib/fs.js index f0e70ce9fc837..cbc87d09d80d3 100644 --- a/src/dev/build/lib/fs.js +++ b/src/dev/build/lib/fs.js @@ -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) { diff --git a/src/dev/build/tasks/clean_tasks.js b/src/dev/build/tasks/clean_tasks.js index 0ee189352167b..05e99db859775 100644 --- a/src/dev/build/tasks/clean_tasks.js +++ b/src/dev/build/tasks/clean_tasks.js @@ -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); } } }, diff --git a/src/dev/build/tasks/nodejs/clean_node_builds_task.js b/src/dev/build/tasks/nodejs/clean_node_builds_task.js index 8abfdcbf10ace..64fd7c6be3a01 100644 --- a/src/dev/build/tasks/nodejs/clean_node_builds_task.js +++ b/src/dev/build/tasks/nodejs/clean_node_builds_task.js @@ -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); } }, }; diff --git a/src/dev/build/tasks/nodejs_modules/webpack_dll.js b/src/dev/build/tasks/nodejs_modules/webpack_dll.js index 367a7e6120e29..4ee2590d4b789 100644 --- a/src/dev/build/tasks/nodejs_modules/webpack_dll.js +++ b/src/dev/build/tasks/nodejs_modules/webpack_dll.js @@ -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; diff --git a/src/dev/build/tasks/optimize_task.js b/src/dev/build/tasks/optimize_task.js index c71f8cc7d9c8b..5dde9990f8e9c 100644 --- a/src/dev/build/tasks/optimize_task.js +++ b/src/dev/build/tasks/optimize_task.js @@ -52,6 +52,6 @@ export const OptimizeBuildTask = { }); // clean up temporary node install - await deleteAll(log, [tempNodeInstallDir]); + await deleteAll([tempNodeInstallDir], log); }, };