-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrename_dict.js
More file actions
29 lines (26 loc) · 880 Bytes
/
rename_dict.js
File metadata and controls
29 lines (26 loc) · 880 Bytes
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
const fs = require('fs');
const path = require('path');
function replaceInFile(filePath) {
let content = fs.readFileSync(filePath, 'utf8');
let updated = content.replace(/consentDict/g, 'consentDict');
if (content !== updated) {
fs.writeFileSync(filePath, updated, 'utf8');
console.log('Updated', filePath);
}
}
function processDir(dir) {
const files = fs.readdirSync(dir);
for (const f of files) {
const fullPath = path.join(dir, f);
if (fs.statSync(fullPath).isDirectory()) {
if (f !== 'node_modules' && f !== '.git' && f !== 'archive') {
processDir(fullPath);
}
} else {
if (fullPath.endsWith('.js') || fullPath.endsWith('.html') || fullPath.endsWith('.json')) {
replaceInFile(fullPath);
}
}
}
}
processDir(__dirname);