google_forms/node_modules/cli-cursor/index.js

40 lines
694 B
JavaScript
Raw Normal View History

2024-08-09 12:04:48 +00:00
import process from 'node:process';
import restoreCursor from 'restore-cursor';
let isHidden = false;
const cliCursor = {};
cliCursor.show = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
return;
}
isHidden = false;
writableStream.write('\u001B[?25h');
};
cliCursor.hide = (writableStream = process.stderr) => {
if (!writableStream.isTTY) {
return;
}
restoreCursor();
isHidden = true;
writableStream.write('\u001B[?25l');
};
cliCursor.toggle = (force, writableStream) => {
if (force !== undefined) {
isHidden = force;
}
if (isHidden) {
cliCursor.show(writableStream);
} else {
cliCursor.hide(writableStream);
}
};
export default cliCursor;