2021-12-07 12:46:03 +00:00
|
|
|
import { existsSync, mkdirSync, writeFileSync } from 'fs'
|
|
|
|
import { join } from 'path'
|
2020-04-23 15:44:41 +00:00
|
|
|
|
2021-12-07 12:46:03 +00:00
|
|
|
const dataDir = new URL('../source/data/', import.meta.url).pathname
|
|
|
|
|
|
|
|
export function createDataDir() {
|
|
|
|
if (!existsSync(dataDir)) {
|
|
|
|
mkdirSync(dataDir)
|
2020-04-23 15:44:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-07 12:46:03 +00:00
|
|
|
export function writeInDataDir(filename, data) {
|
|
|
|
writeFileSync(join(dataDir, filename), JSON.stringify(data, null, 2))
|
2020-04-23 15:44:41 +00:00
|
|
|
}
|