MCPcopy
hub / github.com/upstash/context7 / waitForEnter

Function waitForEnter

packages/cli/src/commands/auth.ts:72–95  ·  view source on GitHub ↗

Prints a prompt and resolves on the next keypress. No-op when stdin isn't a TTY.

(prompt: string)

Source from the content-addressed store, hash-verified

70
71/** Prints a prompt and resolves on the next keypress. No-op when stdin isn't a TTY. */
72function waitForEnter(prompt: string): Promise<void> {
73 if (!process.stdin.isTTY) return Promise.resolve();
74 return new Promise<void>((resolve) => {
75 process.stdout.write(` ${pc.dim(prompt)} `);
76 const onData = (chunk: Buffer) => {
77 // Ctrl-C
78 if (chunk[0] === 0x03) {
79 process.stdin.removeListener("data", onData);
80 process.stdin.setRawMode?.(false);
81 process.stdin.pause();
82 process.stdout.write("\n");
83 process.exit(130);
84 }
85 process.stdin.removeListener("data", onData);
86 process.stdin.setRawMode?.(false);
87 process.stdin.pause();
88 process.stdout.write("\n");
89 resolve();
90 };
91 process.stdin.setRawMode?.(true);
92 process.stdin.resume();
93 process.stdin.on("data", onData);
94 });
95}
96
97async function announceIdentity(accessToken: string): Promise<string> {
98 try {

Callers 1

performLoginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected