UNPKG

starforged-cli

Version:

My goal is for this to be an easy-to-use CLI for playing Starforged solo. If your game ends up in a broken state of some sort, and no command yet exists to fix your issue, all of the game data you accumulate is stored in `~/starforged-cli/db.json` and you

26 lines (20 loc) 509 B
const fs = require("fs/promises"); const FS = require("fs"); const { dbPath, appPath } = require("./constants"); async function readDb() { try { await fs.access(appPath, FS.constants.F_OK); } catch (error) { await fs.mkdir(appPath); } try { await fs.access(dbPath, FS.constants.F_OK); } catch (error) { return {}; } return require(dbPath); } async function writeDb(data) { await fs.writeFile(dbPath, JSON.stringify(data, null, 2)); } module.exports = { readDb, writeDb };