UNPKG

xweb-templating

Version:

A cli tool for converting 'tags' to regular html, php or some other format

38 lines (37 loc) 1.77 kB
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()); }); }; import { read_config, save_config } from "../config/config.js"; import { error, warn } from "../log.js"; import { save_tagsets } from "./util.js"; export default function run(argv) { var _a; return __awaiter(this, void 0, void 0, function* () { const CONFIG = read_config("add/config"); if (!CONFIG.use.tags) { error("add/config", "Cannot add tagset in a project that has disabled tagsets"); return; } if (argv.names == undefined) { error("add/config", "Cannot add tagsets without a name"); return; } const TAGSET_NAMES = (_a = argv.names) === null || _a === void 0 ? void 0 : _a.split(" "); for (const NAME of TAGSET_NAMES) { if (!CONFIG.tags.includes(NAME)) { CONFIG.tags.push(NAME); } else { yield warn("add/config", `Tagset ${NAME} is already found in config file`, argv.y); } } save_config("add/config", CONFIG); save_tagsets("add/fetch", TAGSET_NAMES, CONFIG); }); }