Skip to content

🎥 Make videos programmatically with React

NO_COLOR takes priority over FORCE_COLOR

Jonny Burger9fb766e5eeb8
diff --git a/packages/renderer/src/chalk/index.ts b/packages/renderer/src/chalk/index.ts
index c18b87333a..c55575037b 100644
--- a/packages/renderer/src/chalk/index.ts
+++ b/packages/renderer/src/chalk/index.ts
@@ -1,13 +1,5 @@
import {isColorSupported} from './is-color-supported';
-const hasColor = () => {
- if (typeof process !== 'undefined' && process.env.FORCE_COLOR) {
- return true;
- }
-
- return isColorSupported();
-};
-
type Style = {
codes: [number, number];
name: string;
@@ -67,7 +59,7 @@ type ColorsWithMethods = Colors & {
export const chalk = (() => {
const colors: Colors = {
- enabled: () => hasColor(),
+ enabled: () => isColorSupported(),
visible: true,
styles: {},
keys: {},
diff --git a/packages/renderer/src/chalk/is-color-supported.ts b/packages/renderer/src/chalk/is-color-supported.ts
index ab8f67e959..be89d41f21 100644
--- a/packages/renderer/src/chalk/is-color-supported.ts
+++ b/packages/renderer/src/chalk/is-color-supported.ts
@@ -1,11 +1,19 @@
import * as tty from 'tty';
export const isColorSupported = () => {
- const argv = process.argv || [];
const env = process.env || {};
- const isDisabled = 'NO_COLOR' in env || argv.includes('--no-color');
- const isForced = 'FORCE_COLOR' in env || argv.includes('--color');
+ const isForceDisabled = 'NO_COLOR' in env;
+
+ if (isForceDisabled) {
+ return false;
+ }
+
+ const isForced = 'FORCE_COLOR' in env;
+ if (isForced) {
+ return true;
+ }
+
const isWindows = process.platform === 'win32';
const isCompatibleTerminal =
@@ -15,5 +23,5 @@ export const isColorSupported = () => {
'CI' in env &&
('GITHUB_ACTIONS' in env || 'GITLAB_CI' in env || 'CIRCLECI' in env);
- return !isDisabled && (isForced || isWindows || isCompatibleTerminal || isCI);
+ return isWindows || isCompatibleTerminal || isCI;
};