mon-entreprise/site/scripts/utils.js

16 lines
419 B
JavaScript
Raw Normal View History

2021-12-07 12:46:03 +00:00
import { existsSync, mkdirSync, writeFileSync } from 'fs'
import { join } from 'path'
import { fileURLToPath } from 'url'
const dataDir = join(fileURLToPath(import.meta.url), '..', '..', 'source', 'data')
2021-12-07 12:46:03 +00:00
export function createDataDir() {
if (!existsSync(dataDir)) {
mkdirSync(dataDir)
}
}
2021-12-07 12:46:03 +00:00
export function writeInDataDir(filename, data) {
writeFileSync(join(dataDir, filename), JSON.stringify(data, null, 2))
}