1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-13 03:47:29 +00:00
bibliogram/scripts/export_users.js
2020-02-18 20:07:11 +13:00

12 lines
441 B
JavaScript
Executable File

const fs = require("fs").promises
const pj = require("path").join
const db = require("../src/lib/db")
;(async () => {
const users = db.prepare("SELECT * FROM Users").all()
const targetDir = process.argv.slice(2).includes("--publish") ? "../src/site/html" : ".."
const target = pj(__dirname, targetDir, "users_export.json")
fs.writeFile(target, JSON.stringify(users), {encoding: "utf8"})
console.log(`Users exported to ${target}`)
})()