-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreplace.js
More file actions
34 lines (31 loc) · 1 KB
/
Copy pathreplace.js
File metadata and controls
34 lines (31 loc) · 1 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');
const replacements = {
"201,149,108": "166,101,101",
"201, 149, 108": "166, 101, 101",
"12,9,7": "24,37,38",
"12, 9, 7": "24, 37, 38",
"245,239,232": "240,235,235",
"245, 239, 232": "240, 235, 235"
};
function walk(dir) {
const files = fs.readdirSync(dir);
for (const file of files) {
const filepath = path.join(dir, file);
const stats = fs.statSync(filepath);
if (stats.isDirectory()) {
walk(filepath);
} else if (stats.isFile() && (filepath.endsWith('.tsx') || filepath.endsWith('.ts'))) {
const content = fs.readFileSync(filepath, 'utf8');
let newContent = content;
for (const [oldStr, newStr] of Object.entries(replacements)) {
newContent = newContent.split(oldStr).join(newStr);
}
if (newContent !== content) {
fs.writeFileSync(filepath, newContent, 'utf8');
console.log(`Updated ${filepath}`);
}
}
}
}
walk('d:/Dev/rose-reverie/src/components');