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