@averagehelper/corde
Version:
A simple library for Discord bot tests. (Republished fork to demonstrate a bugfix)
73 lines (72 loc) • 2.97 kB
JavaScript
;
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.program = void 0;
const commander_1 = require("commander");
const go_1 = require("./go");
const init_1 = require("./init");
const validate_1 = require("./validate");
const common_1 = require("../common");
const reader_1 = __importDefault(require("../core/reader"));
const errorHandler_1 = require("../errorHandler");
const package_1 = __importDefault(require("../package"));
errorHandler_1.initErrorHandlers();
exports.program = new commander_1.Command();
// Add basic information with default run all 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("-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((args) => __awaiter(void 0, void 0, void 0, function* () {
const options = exports.program.opts();
if (options.config) {
common_1.runtime.configFilePath = options.config;
}
if (args) {
common_1.runtime.testFiles = exports.program.args;
}
if (options.files) {
common_1.runtime.testFiles = options.files.split(" ");
}
yield go_1.go();
}));
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) => {
init_1.init(type);
});
exports.program
.command("validate")
.alias("v")
.description("Search for corde configs and check if all data are valid")
.action(() => {
const configs = reader_1.default.loadConfig();
validate_1.validate(configs);
console.log("All configs are ok!");
});
// tslint:disable-next-line: deprecation
if (process.env.ENV !== "TEST") {
exports.program.parse(process.argv);
}
else {
exports.program.exitOverride();
}