From af52bbd51e3115f1e415030e48be2863f6acf25b Mon Sep 17 00:00:00 2001 From: dsl101 Date: Wed, 20 Jan 2021 10:00:11 +0000 Subject: [PATCH] Use nice spinner on VSCode's terminal and Windows Terminal (#167) Co-authored-by: Sindre Sorhus --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index db02447..6860f9c 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,12 @@ const PREFIX_TEXT = Symbol('prefixText'); const ASCII_ETX_CODE = 0x03; // Ctrl+C emits this code +const terminalSupportsUnicode = () => ( + process.platform !== 'win32' || + process.env.TERM_PROGRAM === 'vscode' || + Boolean(process.env.WT_SESSION) +); + class StdinDiscarder { constructor() { this.requests = 0; @@ -163,7 +169,7 @@ class Ora { } this._spinner = spinner; - } else if (process.platform === 'win32') { + } else if (!terminalSupportsUnicode()) { this._spinner = cliSpinners.line; } else if (spinner === undefined) { // Set default spinner