From 4c650054b2aec42a7b6b3ba7ea0fa429ea284986 Mon Sep 17 00:00:00 2001 From: Christopher Allen Date: Sun, 20 Aug 2023 01:18:29 +0100 Subject: [PATCH] fix(build): Restore erroneously-deleted filter function This was deleted in PR #7406 as it was mainly being used to filter core/ vs. test/mocha/ deps into separate deps files - but it turns out also to be used for filtering error messages too. Oops. --- scripts/gulpfiles/build_tasks.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/gulpfiles/build_tasks.js b/scripts/gulpfiles/build_tasks.js index 0d751775002..65a48566c4c 100644 --- a/scripts/gulpfiles/build_tasks.js +++ b/scripts/gulpfiles/build_tasks.js @@ -316,6 +316,21 @@ function buildDeps() { /** Maximum buffer size, in bytes for child process stdout/stderr. */ const MAX_BUFFER_SIZE = 10 * 1024 * 1024; + /** + * Filter a string to extract lines containing (or not containing) the + * specified target string. + * + * @param {string} text Text to filter. + * @param {string} target String to search for. + * @param {boolean?} exclude If true, extract only non-matching lines. + * @returns {string} Filtered text. + */ + function filter(text, target, exclude) { + return text.split('\n') + .filter((line) => Boolean(line.match(target)) !== Boolean(exclude)) + .join('\n'); + } + /** * Log unexpected diagnostics, after removing expected warnings. *