UNPKG

ecus-cli

Version:

A Command line interface of ECUS

42 lines (41 loc) 1.88 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFileConfig = exports.updateFileConfig = void 0; const zx_1 = require("zx"); function updateFileConfig(config) { return __awaiter(this, void 0, void 0, function* () { if (!(yield zx_1.fs.exists(".ecus"))) { yield zx_1.fs.ensureDir(".ecus"); console.log(zx_1.chalk.green("created `.ecus/` folder for you which will save your config in local.")); if (yield zx_1.fs.exists(".gitignore")) { const content = yield zx_1.fs.readFile(".gitignore", "utf-8"); if (!content.includes(".ecus/")) { yield zx_1.fs.appendFile(".gitignore", "\n.ecus/\n"); } } } yield zx_1.fs.writeJSON(".ecus/config.json", config); }); } exports.updateFileConfig = updateFileConfig; function getFileConfig() { return __awaiter(this, void 0, void 0, function* () { try { const config = yield zx_1.fs.readJSON(".ecus/config.json"); return config; } catch (_a) { return {}; } }); } exports.getFileConfig = getFileConfig;