Skip to content

Commit

Permalink
disabled discardStdin for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanis Benson committed Nov 12, 2019
1 parent de85060 commit 9392e5e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions example.js
Expand Up @@ -15,6 +15,14 @@ const spinnerDiscardingStdin = new Ora({

spinnerDiscardingStdin.start();

setTimeout(() => {
spinnerDiscardingStdin.succeed();
}, 1000);

setTimeout(() => {
spinnerDiscardingStdin.start();
}, 2000);

setTimeout(() => {
spinnerDiscardingStdin.succeed();
spinner.start();
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Expand Up @@ -93,7 +93,7 @@ declare namespace ora {
readonly isEnabled?: boolean;

/**
Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on `Enter` key presses, and prevents buffering of input while the spinner is running.
Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on `Enter` key presses, and prevents buffering of input while the spinner is running. Have no effect on Windows(always disabled).
@default true
*/
Expand Down
8 changes: 8 additions & 0 deletions index.js
Expand Up @@ -57,6 +57,10 @@ class StdinDiscarder {
}

realStart() {
if (process.platform === 'win32') { // No known method to make it work under windows reliably
return;
}

const {stdin} = process;

this.oldRawMode = stdin.isRaw;
Expand All @@ -71,6 +75,10 @@ class StdinDiscarder {
}

realStop() {
if (process.platform === 'win32') { // No known method to make it work under windows reliably
return;
}

const {stdin} = process;

if (this.oldEmitOwnProperty) {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -122,7 +122,7 @@ Note that `{isEnabled: false}` doesn't mean it won't output anything. It just me
Type: `boolean`<br>
Default: `true`

Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on <kbd>Enter</kbd> key presses, and prevents buffering of input while the spinner is running.
Discard stdin input (except Ctrl+C) while running if it's TTY. This prevents the spinner from twitching on input, outputting broken lines on <kbd>Enter</kbd> key presses, and prevents buffering of input while the spinner is running. Have no effect on Windows(always disabled).

### Instance

Expand Down

0 comments on commit 9392e5e

Please sign in to comment.