mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 23:34:45 +08:00
33 lines
728 B
JavaScript
33 lines
728 B
JavaScript
import fs from "fs"
|
|
function createFile(filePath) {
|
|
if (!fs.existsSync(filePath)) {
|
|
writeFile(filePath, "")
|
|
}
|
|
}
|
|
|
|
function writeFile(filePath, content) {
|
|
fs.writeFile(filePath, content, error => {
|
|
if (error) {
|
|
throw new Error(`${filePath}:写入${content}失败`)
|
|
}
|
|
})
|
|
}
|
|
|
|
function appendFile(filePath, content) {
|
|
fs.appendFile(filePath, content, error => {
|
|
if (error) {
|
|
throw new Error(`${filePath}:追加${content}失败`)
|
|
}
|
|
})
|
|
}
|
|
|
|
function appendFileSync(filePath, content) {
|
|
fs.appendFileSync(filePath, content, error => {
|
|
if (error) {
|
|
throw new Error(`${filePath}:同步追加${content}失败`)
|
|
}
|
|
})
|
|
}
|
|
|
|
export { createFile, writeFile, appendFile, appendFileSync }
|