YesPlayMusic/packages/electron/utils.ts
2022-05-12 02:45:43 +08:00

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, '')
}
}