-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix-aliases.js
More file actions
26 lines (24 loc) · 823 Bytes
/
fix-aliases.js
File metadata and controls
26 lines (24 loc) · 823 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
// Feature: Tooling | Why: Rewrites @alias import paths to relative paths — one-shot migration script
const fs = require('fs');
const path = require('path');
function walk(dir) {
const files = fs.readdirSync(dir);
for (const f of files) {
const p = path.join(dir, f);
if (fs.statSync(p).isDirectory()) {
walk(p);
} else if (p.endsWith('.ts') || p.endsWith('.tsx')) {
let content = fs.readFileSync(p, 'utf8');
let newContent = content.replace(/['"]\.\.\/components\/.*?['"]/g, match => {
return match.replace('../components/', '../../components/');
});
if (content !== newContent) {
fs.writeFileSync(p, newContent);
console.log(`Updated ${p}`);
}
}
}
}
walk('src/features/browser');
walk('src/features/ui');
walk('src/features/settings');