UNPKG

@inlang/paraglide-js

Version:

[![NPM Downloads](https://img.shields.io/npm/dw/%40inlang%2Fparaglide-js?logo=npm&logoColor=red&label=npm%20downloads)](https://www.npmjs.com/package/@inlang/paraglide-js) [![GitHub Issues](https://img.shields.io/github/issues-closed/opral/paraglide-js?lo

43 lines 1.29 kB
import path from "node:path"; import os from "node:os"; export function getLocalAccount(args) { try { const accountPath = getAccountFilePath(); if (!args.fs.existsSync(accountPath)) { return; } return JSON.parse(args.fs.readFileSync(accountPath, "utf8")); } catch { return; } } export function saveLocalAccount(args) { try { const accountPath = getAccountFilePath(); args.fs.mkdirSync(path.dirname(accountPath), { recursive: true }); args.fs.writeFileSync(accountPath, JSON.stringify(args.account, null, 2)); } catch { // do nothing } } /** * Returns the path to the local account file. * * Based on the env-paths package https://github.com/sindresorhus/env-paths/blob/main/index.js */ export function getAccountFilePath() { const homedir = os.homedir(); if (process.platform === "darwin") { return path.join(homedir, "Library", "Application Support", "lix", "account.json"); } else if (process.platform === "win32") { return path.join(homedir, "AppData", "Roaming", "lix", "account.json"); } // linux else { return path.join(homedir, ".local", "share", "lix", "account.json"); } } //# sourceMappingURL=index.js.map