UNPKG

zcatalyst-cli

Version:

Command Line Tool for CATALYST

73 lines (72 loc) 2.26 kB
'use strict'; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const conf_1 = __importDefault(require("conf")); const path_1 = require("path"); const error_1 = __importDefault(require("../error")); const path = process.env['X_ZC_CREDENTIAL_PATH']; class Store { static changeStore(store, path) { switch (store) { case 'cli': { Store._store = new conf_1.default({ configName: 'zcatalyst-cli', projectName: 'zcatalyst-cli', cwd: path }); return; } case 'vscode': { Store._store = new conf_1.default({ configName: 'auth', projectName: 'zcatalyst-vscode', cwd: path ? (0, path_1.join)(path, 'zcatalyst-vscode') : undefined }); return; } case 'zcode': { Store._store = new conf_1.default({ configName: 'auth', projectName: 'zcatalyst-zcode', cwd: path ? (0, path_1.join)(path, 'zcatalyst-code') : undefined }); return; } default: { throw new error_1.default('Invalid Store type: ' + store, { exit: 2 }); } } } static get istore() { return Store._store; } static get path() { return (0, path_1.join)(this._store.path, '../../'); } static get store() { return Store.istore.store; } static set store(val) { Store.istore.store = val; } static set(key, value) { return Store.istore.set(key, value); } static get(key, fallback) { return Store.istore.get(key, fallback); } static delete(key) { return Store.istore.delete(key); } static has(key) { return Store.istore.has(key); } } Store._store = new conf_1.default({ configName: 'zcatalyst-cli', projectName: 'zcatalyst-cli', cwd: path }); exports.default = Store;