-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfix_styles.cjs
More file actions
27 lines (27 loc) · 816 Bytes
/
fix_styles.cjs
File metadata and controls
27 lines (27 loc) · 816 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
const fs = require('fs');
const path = require('path');
function walk(dir) {
let results = [];
const list = fs.readdirSync(dir);
list.forEach(file => {
file = dir + '/' + file;
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(walk(file));
} else {
if (file.endsWith('.tsx') || file.endsWith('.ts')) results.push(file);
}
});
return results;
}
const files = walk('src');
let changedCount = 0;
files.forEach(f => {
let content = fs.readFileSync(f, 'utf8');
if (content.includes("'../styles/")) {
content = content.replace(/'\.\.\/styles\//g, "'@/styles/");
fs.writeFileSync(f, content);
changedCount++;
}
});
console.log(`Changed ${changedCount} files.`);