code-theme-converter
Version:
Convert any vscode theme with ease!
47 lines (46 loc) • 1.84 kB
JavaScript
;
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("../sublime/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('-S, --save', 'Install theme into Sublime Text', false)
.option('-T, --as-tm-theme', 'Convert to .tmTheme instead of .sublime-color-scheme', false)
.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.convertToSublime(repoUrl, options)
.then(() => {
console.log(chalk_1.default.green('🎉 Successfully converted the vscode theme for sublime text!'));
})
.catch(err => {
console.error(chalk_1.default.red(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;
}