UNPKG

@unibeautify/cli

Version:
60 lines 2.49 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const utils_1 = require("../utils"); const BaseCommand_1 = require("./BaseCommand"); class SupportCommand extends BaseCommand_1.BaseCommand { constructor() { super(...arguments); this.jsonPrinter = (info) => { this.writeOut(JSON.stringify(info, null, 2)); // unibeautify:ignore-next-line }; this.listPrinter = (info) => { Object.keys(info).forEach(section => { this.writeOutHeading(`Supported ${section}`); const items = info[section]; items.forEach((item, index) => this.writeOut(`${index + 1}. ${item}`)); }); // unibeautify:ignore-next-line }; } support(options) { const printer = options.json ? this.jsonPrinter : this.listPrinter; const info = {}; return utils_1.setupUnibeautify().then((unibeautify) => __awaiter(this, void 0, void 0, function* () { if (options.languages) { if (options.all) { info["languages"] = utils_1.getAllLanguages(); } else { info["languages"] = utils_1.getSupportedLanguages(); } } if (options.beautifiers) { const beautifiers = yield utils_1.findInstalledBeautifiers(); info["beautifiers"] = beautifiers; } if (Object.keys(info).length === 0) { this.writeError("Nothing to show"); // this.exit(1); this.exitCode = 1; } else { printer(info); // this.exit(0); } })); } } exports.SupportCommand = SupportCommand; //# sourceMappingURL=SupportCommand.js.map