UNPKG

@xgheaven/nos-cli

Version:
33 lines (32 loc) 1.04 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var fs = __importStar(require("fs")); var os_1 = require("os"); var path = __importStar(require("path")); var configPath = path.join(os_1.homedir(), '.nosrc'); var defaultConfig = { accounts: {}, }; function getConfig() { if (fs.existsSync(configPath)) { try { return Object.assign({}, defaultConfig, JSON.parse(fs.readFileSync(configPath, 'utf8'))); } catch (e) { return Object.assign({}, defaultConfig); } } return Object.assign({}, defaultConfig); } exports.getConfig = getConfig; function setConfig(config) { return fs.writeFileSync(configPath, JSON.stringify(config)); } exports.setConfig = setConfig;