1
0
mirror of https://git.sr.ht/~cadence/bibliogram synced 2024-11-01 05:57:29 +00:00
bibliogram/scripts/export_users.js

12 lines
441 B
JavaScript
Raw Normal View History

2020-02-18 07:07:11 +00:00
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}`)
})()