Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use simpler CI detection #638

Merged
merged 1 commit into from Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is-in-ci already has this check

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