-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace_colors.js
More file actions
34 lines (30 loc) · 1.13 KB
/
Copy pathreplace_colors.js
File metadata and controls
34 lines (30 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require('fs');
const path = require('path');
function walk(dir) {
let results = [];
const list = fs.readdirSync(dir);
list.forEach(file => {
file = path.join(dir, file);
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(walk(file));
} else if (file.endsWith('.tsx') || file.endsWith('.ts') || file.endsWith('.css')) {
results.push(file);
}
});
return results;
}
const files = walk('frontend/src');
files.forEach(file => {
let content = fs.readFileSync(file, 'utf8');
let original = content;
content = content.replace(/\[#D4AF37\]/g, 'theme');
content = content.replace(/['"]#D4AF37['"]/g, '"var(--brand-primary)"');
// Replace the specific rgb shadow glowing strings
content = content.replace(/rgba\(212,175,55,([0-9.]+)\)/g, 'rgba(var(--brand-primary-rgb),$1)');
content = content.replace(/rgba\(212, 175, 55, ([0-9.]+)\)/g, 'rgba(var(--brand-primary-rgb), $1)');
if (content !== original) {
fs.writeFileSync(file, content);
console.log('Updated: ' + file);
}
});