UNPKG

code-theme-converter

Version:

Convert any vscode theme with ease!

45 lines (44 loc) 1.67 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const chalk_1 = __importDefault(require("chalk")); const commander_1 = require("commander"); const convert_1 = require("../idea/convert"); const program = commander_1.createCommand(); program .version(require('../../package').version) .usage('<repo-url> [options]') .description('Converts a vscode-theme into the sublime-text theme syntax') .option('-d, --directory [name]', 'Overwrite directory containing the themes', 'themes') .parse(process.argv); if (process.argv.length < 1) { program.outputHelp(); } if (program.args.length > 1) { console.warn(chalk_1.default.yellow('You have provided more than one argument. Only the first argument will be used!')); } const repoUrl = program.args[0]; const options = cleanArgs(program); if (repoUrl != '') { convert_1.convertToIdea(repoUrl, options) .then(() => { console.log(chalk_1.default.green('🎉 Successfully converted the vscode theme for IDEA!')); }) .catch(err => { console.trace(chalk_1.default.red(err), err); }); } function cleanArgs(cmd) { const args = {}; cmd.options.forEach((option) => { const key = option.long.replace(/^--/, ''); // if an option is not present and Command has a method with the same name // it should not be copied if (typeof cmd[key] != 'function' && typeof cmd[key] != 'undefined') { args[key] = cmd[key]; } }); return args; }