From dd32f4bc420babc1107e9f1dd1929306503fe1ce Mon Sep 17 00:00:00 2001 From: ElenaDiachenko Date: Mon, 18 Nov 2024 15:07:09 +0200 Subject: [PATCH] fix override when the original and the override have overlapping substrings (cherry picked from commit 15cce6c45b64a7a217aac6eacab27eb6a90098e1) --- packages/core/src/plugins/index.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/core/src/plugins/index.ts b/packages/core/src/plugins/index.ts index e641719bf..7f4779cf9 100644 --- a/packages/core/src/plugins/index.ts +++ b/packages/core/src/plugins/index.ts @@ -830,9 +830,26 @@ export const overrideFileContents = ( )}. FIXING...DONE` ); } else if (overrideExists) { - logInfo( - `${chalk().gray(dest)} overridden by: ${chalk().gray(overridePath.split('node_modules').pop())}` - ); + if (originalExists) { + if (fk.includes(override[fk])) { + fileToFix = fileToFix.replace(originalRegEx, `${override[fk]}`); + logSuccess( + `${chalk().bold.white(dest)} requires override by: ${chalk().bold.white( + overridePath.split('node_modules').pop() + )}. FIXING...DONE` + ); + } else { + logInfo( + `${chalk().gray(dest)} overridden by: ${chalk().gray( + overridePath.split('node_modules').pop() + )}` + ); + } + } else { + logInfo( + `${chalk().gray(dest)} overridden by: ${chalk().gray(overridePath.split('node_modules').pop())}` + ); + } } else { failTerms.push(fk); }