Skip to content

Commit

Permalink
Use simpler CI detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 9, 2023
1 parent 6795962 commit 670ebc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -53,7 +53,7 @@
"cli-truncate": "^4.0.0",
"code-excerpt": "^4.0.0",
"indent-string": "^5.0.0",
"is-ci": "^3.0.1",
"is-in-ci": "^0.1.0",
"lodash": "^4.17.21",
"patch-console": "^2.0.0",
"react-reconciler": "^0.29.0",
Expand All @@ -72,7 +72,6 @@
"@faker-js/faker": "^8.2.0",
"@sindresorhus/tsconfig": "^5.0.0",
"@types/benchmark": "^2.1.2",
"@types/is-ci": "^2.0.0",
"@types/lodash": "^4.14.191",
"@types/ms": "^0.7.31",
"@types/node": "*",
Expand Down
15 changes: 7 additions & 8 deletions src/ink.tsx
Expand Up @@ -3,7 +3,7 @@ import React, {type ReactNode} from 'react';
import throttle from 'lodash/throttle.js';
import {type DebouncedFunc} from 'lodash';
import ansiEscapes from 'ansi-escapes';
import originalIsCi from 'is-ci';
import isInCi from 'is-in-ci';
import autoBind from 'auto-bind';
import signalExit from 'signal-exit';
import patchConsole from 'patch-console';
Expand All @@ -16,7 +16,6 @@ import logUpdate, {type LogUpdate} from './log-update.js';
import instances from './instances.js';
import App from './components/App.js';

const isCi = process.env['CI'] === 'false' ? false : originalIsCi;
const noop = () => {};

export type Options = {
Expand Down Expand Up @@ -108,7 +107,7 @@ export default class Ink {
this.patchConsole();
}

if (!isCi) {
if (!isInCi) {
options.stdout.on('resize', this.resized);

this.unsubscribeResize = () => {
Expand Down Expand Up @@ -159,7 +158,7 @@ export default class Ink {
return;
}

if (isCi) {
if (isInCi) {
if (hasStaticOutput) {
this.options.stdout.write(staticOutput);
}
Expand Down Expand Up @@ -222,7 +221,7 @@ export default class Ink {
return;
}

if (isCi) {
if (isInCi) {
this.options.stdout.write(data);
return;
}
Expand All @@ -243,7 +242,7 @@ export default class Ink {
return;
}

if (isCi) {
if (isInCi) {
this.options.stderr.write(data);
return;
}
Expand Down Expand Up @@ -273,7 +272,7 @@ export default class Ink {

// CIs don't handle erasing ansi escapes well, so it's better to
// only render last frame of non-static output
if (isCi) {
if (isInCi) {
this.options.stdout.write(this.lastOutput + '\n');
} else if (!this.options.debug) {
this.log.done();
Expand Down Expand Up @@ -303,7 +302,7 @@ export default class Ink {
}

clear(): void {
if (!isCi && !this.options.debug) {
if (!isInCi && !this.options.debug) {
this.log.clear();
}
}
Expand Down

0 comments on commit 670ebc3

Please sign in to comment.