-
Notifications
You must be signed in to change notification settings - Fork 2
/
assets.mjs
40 lines (31 loc) · 988 Bytes
/
assets.mjs
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
// The purpose of this script is to output the js file of the build result so that it can be submitted to the Chrome Web Store for review.
import fs from "fs/promises"
import path from "path"
const directoryPath = "./build/chrome-mv3-prod"
const jsFiles = []
async function readDirectory(dirPath) {
try {
const files = await fs.readdir(dirPath)
await Promise.all(
files.map(async (file) => {
const filePath = path.join(dirPath, file)
const stats = await fs.stat(filePath)
if (stats.isDirectory()) {
if (filePath !== path.join(directoryPath, "static")) {
await readDirectory(filePath)
}
} else if (file.endsWith(".js")) {
jsFiles.push(file)
}
})
)
} catch (err) {
console.error("Error reading directory:", err)
}
}
async function main() {
await readDirectory(directoryPath)
const concatenatedNames = jsFiles.join(",")
console.log(concatenatedNames)
}
main()