From d05506eaab6294e1c33921fe960fe34386d28af8 Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Mon, 30 Sep 2024 09:40:44 -0400 Subject: [PATCH] fix(class-name-updater): ignore css vars when running in v6 mode (#778) --- packages/class-name-updater/src/classNameUpdate.ts | 7 ++++--- packages/class-name-updater/test/test.css | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/class-name-updater/src/classNameUpdate.ts b/packages/class-name-updater/src/classNameUpdate.ts index 01ee76bbf..bc2df0676 100644 --- a/packages/class-name-updater/src/classNameUpdate.ts +++ b/packages/class-name-updater/src/classNameUpdate.ts @@ -16,10 +16,11 @@ export async function classNameUpdate( const isPostV5 = pfVersion > 5; const previousVersion = isPostV5 ? "-v" + (pfVersion - 1) : ""; const classNameMatches = "[cul]"; - const cssVarMatches = `${classNameMatches}|global|theme|color`; + const cssVarMatches = `${classNameMatches}|global|theme|color|chart`; const bodyMatches = isPostV5 ? classNameMatches : cssVarMatches; + const cssVarStart = isPostV5 ? "[^-]" : ""; const changeNeededRegex = new RegExp( - "(\\b|\\$)pf" + previousVersion + `-(${bodyMatches})-`, + `(${cssVarStart})` + "(\\b|\\$)pf" + previousVersion + `-(${bodyMatches})-`, "g" ); const newVersion = pfVersion || 5; @@ -47,7 +48,7 @@ export async function classNameUpdate( const newContent = fileContent.replace( changeNeededRegex, - `$1pf-v${newVersion}-$2-` + `$1$2pf-v${newVersion}-$3-` ); printDiff(file, fileContent, newContent, changeNeededRegex); diff --git a/packages/class-name-updater/test/test.css b/packages/class-name-updater/test/test.css index b4b1b7172..cb50e0ccd 100644 --- a/packages/class-name-updater/test/test.css +++ b/packages/class-name-updater/test/test.css @@ -11,6 +11,7 @@ } .pf-c-console__actions > div { margin-right: var(--pf-v5-global--spacer--sm); + box-shadow: var(--pf-v5-c-wizard__toggle--BoxShadow); } .pf-m-selectable {