Skip to content

Commit bbe03e0

Browse files
committed
chore(build): clean invalid JSON from theming CSS via postinstall
1 parent 1d9a0b6 commit bbe03e0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"prepare": "husky install",
6767
"husky:commit-msg": "commitlint -e",
6868
"husky:pre-push": "npm-run-all --sequential husky:commit-msg",
69-
"postinstall": "patch-package"
69+
"postinstall": "node scripts/clean-theming-css.cjs"
7070
},
7171
"devDependencies": {
7272
"@commitlint/cli": "^16.2.3",

scripts/clean-theming-css.cjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
const glob = require("glob");
4+
5+
// Pattern to match CSS variable definitions with JSON objects
6+
const invalidLinePattern = /--sapThemeMetaData-[^:]+:\{[^;]+};/g;
7+
8+
// Find all matching CSS files
9+
const cssFiles = glob.sync("node_modules/@sap-theming/theming-base-content/content/Base/baseLib/*/css_variables.css");
10+
11+
cssFiles.forEach(file => {
12+
let content = fs.readFileSync(file, "utf8");
13+
// Remove all invalid lines
14+
const cleaned = content.replace(invalidLinePattern, "");
15+
if (content !== cleaned) {
16+
fs.writeFileSync(file, cleaned, "utf8");
17+
console.log(`Cleaned: ${file}`);
18+
}
19+
});

0 commit comments

Comments
 (0)