validatees
Version:
✅ Validation library for ES6+ modules
51 lines (50 loc) • 2.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const repl_1 = __importDefault(require("repl"));
const _1 = require(".");
const check_version_1 = __importDefault(require("./check-version"));
const help_1 = __importDefault(require("./help"));
const main = () => {
(0, _1.logger)("Starting shell mode...", "34", "Info");
(0, check_version_1.default)(false);
(0, _1.logger)("Spawning node shell...", "34", "Info");
const child = (0, child_process_1.spawn)("node");
child.stdout.pipe(process.stdout);
process.stdin.pipe(child.stdin);
(0, _1.logger)("Creating repl...", "34", "Info");
(0, _1.logger)("Setting up validatees functions...", "34", "Info");
const shell = repl_1.default.start({
prompt: "validatees:$ ",
useColors: true,
useGlobal: true,
input: process.stdin,
output: process.stdout,
});
shell.write(`const validatees = require('validatees');Object.keys(validatees).forEach((key) => {global[key] = validatees[key];}); \r\n`);
console.info("version: ", (0, child_process_1.execSync)("cd ../../ && npm view validatees version").toString().trim());
console.info("\x1b[1m\x1b[32m%s\x1b[0m", "Info:", `Validatees shell is ready.
Type 'exit' to exit the shell.
Type '?help' to get help.`);
shell.on("line", (line) => {
if (line === "exit" || line === "quit") {
(0, _1.logger)("Recieved exit command...", "34", "Info");
shell.close();
}
else if (line === "?help") {
(0, _1.logger)("Showing help...", "34", "Info");
console.info("\x1b[1m\x1b[32m%s\x1b[0m", "Info:", help_1.default.getHelpTextInShell());
}
});
shell.on("exit", () => {
(0, _1.logger)("Exiting shell...", "34", "Info");
console.info("\x1b[1m\x1b[32m%s\x1b[0m", "Goodbye!", "Thank you for using validatees!");
return process.exit(0);
});
(0, _1.logger)("Shell is ready...", "34", "Info");
shell.prompt();
};
exports.default = main;