-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix-trace-off.ts
40 lines (30 loc) · 911 Bytes
/
fix-trace-off.ts
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
35
36
37
38
39
40
import * as fs from "fs"
import * as path from "path"
const getAllFiles = function (dirPath: string, input?: string[]) {
const files = fs.readdirSync(dirPath)
let arrayOfFiles = input || []
files.forEach(function (file) {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
} else {
arrayOfFiles.push(path.join(__dirname, dirPath, "/", file))
}
})
return arrayOfFiles
}
const files = getAllFiles("./src")
const fixup = (file: string) => {
const content = fs.readFileSync(file).toString("utf-8")
if (content) {
let fixedContent = content
if (!fixedContent.match("// ets_tracing: off")) {
fixedContent = "// ets_tracing: off\n\n" + fixedContent
}
if (fixedContent !== content) {
fs.writeFileSync(file, fixedContent)
}
}
}
files.forEach((file) => {
fixup(file)
})