Skip to content

Commit

Permalink
Use nice spinner on VSCode's terminal and Windows Terminal (#167)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
dsl101 and sindresorhus authored Jan 20, 2021
1 parent 705a473 commit af52bbd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af52bbd

Please sign in to comment.