@within-7/jetr 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +23 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -494,11 +494,30 @@ program.command("login").description("Login with username and password").argumen
|
|
|
494
494
|
}
|
|
495
495
|
if (!password) {
|
|
496
496
|
const rl = createInterface2({ input: process.stdin, output: process.stdout });
|
|
497
|
+
process.stdout.write("Password: ");
|
|
498
|
+
const stdin = process.stdin;
|
|
499
|
+
const wasRaw = stdin.isRaw;
|
|
500
|
+
if (stdin.isTTY) stdin.setRawMode(true);
|
|
497
501
|
password = await new Promise((res) => {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
+
let buf = "";
|
|
503
|
+
const onData = (ch) => {
|
|
504
|
+
const c = ch.toString();
|
|
505
|
+
if (c === "\n" || c === "\r" || c === "") {
|
|
506
|
+
if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
|
|
507
|
+
stdin.removeListener("data", onData);
|
|
508
|
+
process.stdout.write("\n");
|
|
509
|
+
rl.close();
|
|
510
|
+
res(buf);
|
|
511
|
+
} else if (c === "") {
|
|
512
|
+
if (stdin.isTTY) stdin.setRawMode(wasRaw ?? false);
|
|
513
|
+
process.exit(1);
|
|
514
|
+
} else if (c === "\x7F" || c === "\b") {
|
|
515
|
+
buf = buf.slice(0, -1);
|
|
516
|
+
} else {
|
|
517
|
+
buf += c;
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
stdin.on("data", onData);
|
|
502
521
|
});
|
|
503
522
|
}
|
|
504
523
|
if (!user || !password) {
|