-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
71 lines (71 loc) · 2.75 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"use strict";
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_process_1 = require("node:process");
const prompt_1 = require("./prompt");
const utils_1 = require("./utils");
const questions_1 = require("./questions");
const args_1 = require("./args");
const executors_1 = require("./executors");
// if (!stdin.isTTY || stdin.setRawMode === undefined) {
// console.log(
// "This console does not support TTY, please use 'winpty mm' or the 'mmk'-command instead."
// );
// process.exit(1);
// }
// TODO make type for command
// if (
// process.argv[0]
// .substring(process.argv[0].lastIndexOf(path.sep) + 1)
// .startsWith("node")
// )
process.argv.splice(0, 1);
process.argv.splice(0, 1);
if (process.argv[0] === "dryrun") {
(0, utils_1.setDryrun)();
process.argv.splice(0, 1);
}
(0, args_1.initializeArgs)(process.argv.flatMap((x) => x.startsWith("-")
? x
.substring(1)
.split("")
.map((x) => `-${x}`)
: [x]));
if (node_process_1.stdin.isTTY) {
// without this, we would only get streams once enter is pressed
node_process_1.stdin.setRawMode(true);
// resume stdin in the parent process (node app won't quit all by itself
// unless an error or process.exit() happens)
node_process_1.stdin.resume();
// i don't want binary, do you?
node_process_1.stdin.setEncoding("utf8");
// You can always exit with crtl-c
node_process_1.stdin.on("data", (key) => {
let k = key.toString();
if (k === prompt_1.CTRL_C) {
(0, utils_1.abort)();
}
});
}
// TODO Change join to invite
// TODO roles
(() => __awaiter(void 0, void 0, void 0, function* () {
(0, utils_1.checkVersion)();
let token = yield (0, questions_1.start)();
}))().catch((e) => {
(0, prompt_1.exit)();
if (("" + e).includes("Permission denied")) {
(0, executors_1.addKnownHost)();
console.log("\x1b[31mAn error occurred, please try again. If the problem persists reach out on http://discord.merrymake.eu \x1b[0m", e);
}
console.log("\x1b[31mERROR %s\x1b[0m", e);
process.exit(0);
});