Add error case
This commit is contained in:
parent
cedbab4989
commit
987e79c592
@ -20,7 +20,10 @@ export const TerminalUtils = {
|
|||||||
|
|
||||||
/** Queries the terminal for the current cursor position */
|
/** Queries the terminal for the current cursor position */
|
||||||
async getCursorPosition(): Promise<CursorPosition> {
|
async getCursorPosition(): Promise<CursorPosition> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!process.stdin.isTTY || !process.stdout.isTTY)
|
||||||
|
reject(new Error('Not running in a terminal environment!'));
|
||||||
|
|
||||||
const stdin = process.stdin;
|
const stdin = process.stdin;
|
||||||
stdin.setRawMode(true);
|
stdin.setRawMode(true);
|
||||||
stdin.resume();
|
stdin.resume();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user