Skip to content

Commit

Permalink
fix: 🐛 issue when process.stdin could be not an interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaiklor committed Mar 25, 2020
1 parent 7ccfa88 commit 5055370
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/kittik-deck/src/Deck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Canvas } from 'terminal-canvas';
import { DeckDeclaration } from './DeckDeclaration';
import { Slide } from 'kittik-slide';
import readline from 'readline';
import tty from 'tty';

export { DeckDeclaration } from './DeckDeclaration';

Expand Down Expand Up @@ -32,9 +33,12 @@ export class Deck {
}

private initKeyboard (): void {
if (process.stdin instanceof tty.ReadStream) {
process.stdin.setRawMode(true);
process.stdin.setEncoding('utf8');
}

readline.emitKeypressEvents(process.stdin);
process.stdin.setRawMode(true);
process.stdin.setEncoding('utf8');
process.stdin.on('keypress', this.onKeyPress.bind(this));
}

Expand Down

0 comments on commit 5055370

Please sign in to comment.