Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
fix(doctor): replace commander-based interactivity check with tty/ci …
Browse files Browse the repository at this point in the history
…check (#4672)
  • Loading branch information
byCedric authored Mar 28, 2023
1 parent b679e87 commit 2c77f63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/expo-doctor/src/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { boolish } from 'getenv';

class Env {
/** Is running in non-interactive CI mode */
get CI() {
return boolish('CI', false);
}

/** Enable debug logging */
get EXPO_DEBUG() {
return boolish('EXPO_DEBUG', false);
Expand Down
6 changes: 6 additions & 0 deletions packages/expo-doctor/src/utils/interactive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { env } from './env';

/** Determine if the current process is interactive, and can receive user input */
export function isInteractive(): boolean {
return !env.CI && process.stdout.isTTY;
}
6 changes: 4 additions & 2 deletions packages/expo-doctor/src/utils/ora.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import chalk from 'chalk';
import program from 'commander';
import oraReal, { Ora } from 'ora';

import { env } from './env';
import { isInteractive } from './interactive';

// eslint-disable-next-line no-console
const logReal = console.log;
// eslint-disable-next-line no-console
Expand All @@ -19,7 +21,7 @@ const errorReal = console.error;
*/
export function ora(options?: oraReal.Options | string): oraReal.Ora {
const inputOptions = typeof options === 'string' ? { text: options } : options || {};
const disabled = program.nonInteractive;
const disabled = !isInteractive() || env.EXPO_DEBUG;
const spinner = oraReal({
// Ensure our non-interactive mode emulates CI mode.
isEnabled: !disabled,
Expand Down

0 comments on commit 2c77f63

Please sign in to comment.