@enspirit/emb
Version:
A replacement for our Makefile-for-monorepos
18 lines (17 loc) • 439 B
JavaScript
export function enableRawMode(stdin) {
const wasRaw = stdin.isRaw;
const { isTTY } = stdin;
if (isTTY) {
stdin.setRawMode?.(true);
stdin.resume();
// Do NOT set encoding; keep it binary so control chars pass through.
}
return () => {
if (isTTY) {
stdin.setRawMode?.(Boolean(wasRaw));
if (!wasRaw) {
stdin.pause();
}
}
};
}