UNPKG

corde

Version:

A simple library for Discord bot tests

73 lines (58 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true, }); exports._main = exports.program = void 0; const tslib_1 = require("tslib"); const commander_1 = require("commander"); const exec_1 = require("./exec"); const init_1 = require("./init"); const validate_1 = require("./validate"); const package_1 = (0, tslib_1.__importDefault)(require("../package")); const reader_1 = require("../core/reader"); const envVariables_1 = require("../envVariables"); const errorHandler_1 = require("../errorHandler"); (0, errorHandler_1.initErrorHandlers)(); (0, envVariables_1.initEnvVariables)(); exports.program = new commander_1.Command(); exports.program .name("Corde") .usage("to start testings o corde [option] to use a specific command.") .description(package_1.default.description) .version(`v${package_1.default.version}`, "-v, --version"); exports.program .option("-c, --config <type>", "Set config file path") .option("-p, --project <type>", "Set tsconfig path") .option( "-f, --files <path>", "Set the path for all tests. Use this if you wan to specify a single path." + " for Array, use only 'corde <path1> <path2>'", ) .action(async () => { const options = exports.program.opts(); await (0, exec_1.exec)(options); }); exports.program .command("init [type]") .alias("i") .description("Initialize a config file with all possible options") .usage("[js ts json] or empty for default type (json)") .action((type) => { (0, init_1.init)(type); }); exports.program .command("validate") .alias("v") .description("Search for corde configs and check if all data are valid") .action(async () => { const configs = reader_1.reader.loadConfig(); await (0, validate_1.validate)(configs); console.log("All configs are ok!"); }); if (process.env.ENV !== "UNITY_TEST" && process.env.ENV !== "E2E_TEST") { _main(); } async function _main(args) { await exports.program.parseAsync(args ?? process.argv); } exports._main = _main;