From 9392e5e40cbb27b5bb3edc0218847bef91539d3f Mon Sep 17 00:00:00 2001 From: Yanis Benson Date: Tue, 12 Nov 2019 17:42:25 +0300 Subject: [PATCH] disabled discardStdin for windows --- example.js | 8 ++++++++ index.d.ts | 2 +- index.js | 8 ++++++++ readme.md | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/example.js b/example.js index 1a6585d..9d04be3 100644 --- a/example.js +++ b/example.js @@ -15,6 +15,14 @@ const spinnerDiscardingStdin = new Ora({ spinnerDiscardingStdin.start(); +setTimeout(() => { + spinnerDiscardingStdin.succeed(); +}, 1000); + +setTimeout(() => { + spinnerDiscardingStdin.start(); +}, 2000); + setTimeout(() => { spinnerDiscardingStdin.succeed(); spinner.start(); diff --git a/index.d.ts b/index.d.ts index e478463..8642fb7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 */ diff --git a/index.js b/index.js index 24995a0..a23b205 100644 --- a/index.js +++ b/index.js @@ -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; @@ -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) { diff --git a/readme.md b/readme.md index c42b8fe..efe6061 100644 --- a/readme.md +++ b/readme.md @@ -122,7 +122,7 @@ Note that `{isEnabled: false}` doesn't mean it won't output anything. It just me Type: `boolean`
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 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). ### Instance