mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2024-12-04 14:43:52 +08:00
16 lines
343 B
TypeScript
16 lines
343 B
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
export const createDirIfNotExist = (dir: string) => {
|
|
if (!fs.existsSync(dir)) {
|
|
fs.mkdirSync(dir, { recursive: true })
|
|
}
|
|
}
|
|
|
|
export const createFileIfNotExist = (file: string) => {
|
|
createDirIfNotExist(path.dirname(file))
|
|
if (!fs.existsSync(file)) {
|
|
fs.writeFileSync(file, '')
|
|
}
|
|
}
|