Skip to content

Commit

Permalink
fix(@clack/core): keyboard input not working after await in spinner (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Feb 21, 2024
2 parents 90f8e3d + a04e418 commit d9e21c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/olive-walls-clean.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clack/core': patch
---

fix(@clack/core): keyboard input not working after await in spinner
6 changes: 5 additions & 1 deletion packages/core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { stdin, stdout } from 'node:process';
import * as readline from 'node:readline';
import { cursor } from 'sisteransi';

const isWindows = globalThis.process.platform.startsWith('win');

export function block({
input = stdin,
output = stdout,
Expand Down Expand Up @@ -40,7 +42,9 @@ export function block({
return () => {
input.off('keypress', clear);
if (hideCursor) process.stdout.write(cursor.show);
if (input.isTTY) input.setRawMode(false);

// Prevent Windows specific issues: https://github.com/natemoo-re/clack/issues/176
if (input.isTTY && !isWindows) input.setRawMode(false);

// @ts-expect-error fix for https://github.com/nodejs/node/issues/31762#issuecomment-1441223907
rl.terminal = false;
Expand Down

0 comments on commit d9e21c9

Please sign in to comment.