-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (29 loc) · 993 Bytes
/
index.js
File metadata and controls
34 lines (29 loc) · 993 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
28
29
30
31
32
33
34
/* eslint-disable @typescript-eslint/no-shadow */
const fs = require("fs");
const path = require("path");
const rootDir = path.resolve(__dirname, "..");
const buildDir = `${rootDir}/build`;
// 讀取bless.txt的內容
fs.readFile(`${rootDir}/god-bless/bless.txt`, "utf8", (err, data) => {
if (err) {
console.error("❌ 讀取檔案時發生錯誤:", err);
return;
}
// 讀取index.html的內容
fs.readFile(`${buildDir}/index.html`, "utf8", (err, htmlData) => {
if (err) {
console.error("❌ 讀取檔案時發生錯誤:", err);
return;
}
// 在index.html的最上方插入bless.txt的內容
const updatedHtml = `${data}\n${htmlData}`;
// 寫回更新後的內容到index.html
fs.writeFile(`${buildDir}/index.html`, updatedHtml, "utf8", (err) => {
if (err) {
console.error("❌ 寫入檔案時發生錯誤:", err);
} else {
console.log("✅ 成功插入內容到index.html");
}
});
});
});