16 lines
419 B
JavaScript
16 lines
419 B
JavaScript
import { existsSync, mkdirSync, writeFileSync } from 'fs'
|
|
import { join } from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const dataDir = join(fileURLToPath(import.meta.url), '..', '..', 'source', 'data')
|
|
|
|
export function createDataDir() {
|
|
if (!existsSync(dataDir)) {
|
|
mkdirSync(dataDir)
|
|
}
|
|
}
|
|
|
|
export function writeInDataDir(filename, data) {
|
|
writeFileSync(join(dataDir, filename), JSON.stringify(data, null, 2))
|
|
}
|