-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset.js
34 lines (26 loc) · 881 Bytes
/
set.js
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
// dist 폴더에 있는 모든 .js .ts 파일들에서 `var IS_DIST = false;`를 찾아서 `var IS_DIST = true;`로 바꾸는 스크립트
const fs = require('fs');
const path = require('path');
const distPath = path.join(__dirname, 'DateTime');
dfs(distPath);
function dfs(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()) {
console.log(filePath);
dfs(filePath);
}
else if (file.endsWith('.js') || file.endsWith('.ts')) {
update(filePath);
}
}
}
function update(filePath) {
const content = fs.readFileSync(filePath, 'utf-8')
.replace('var IS_DIST = false;', 'var IS_DIST = true;')
.replace(/\((['"])\.\.\/src/g, "($1datetime");
fs.writeFileSync(filePath, content, 'utf-8');
console.log(`${filePath} is updated`);
}