Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions packages/cli-kit/src/public/node/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ describe('cli', () => {
expect(env.FORCE_COLOR).toBe('0')
})

test('triggers no colour mode based on --json flag', async () => {
const launchCLI = vi.fn()
const env = {} as any
await runCLI({moduleURL: 'test', development: false}, launchCLI, ['--json'], env)
expect(env.FORCE_COLOR).toBe('0')
})

test('triggers no colour mode based on -j flag', async () => {
const launchCLI = vi.fn()
const env = {} as any
await runCLI({moduleURL: 'test', development: false}, launchCLI, ['-j'], env)
expect(env.FORCE_COLOR).toBe('0')
})

test('triggers no colour mode based on NO_COLOR environment variable', async () => {
const launchCLI = vi.fn()
const env = {NO_COLOR: 'TRUE'} as any
Expand Down
2 changes: 2 additions & 0 deletions packages/cli-kit/src/public/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function setupEnvironmentVariables(
function forceNoColor(argv: string[] = process.argv, env: NodeJS.ProcessEnv = process.env) {
if (
argv.includes('--no-color') ||
argv.includes('--json') ||
argv.includes('-j') ||
isTruthy(env.NO_COLOR) ||
isTruthy(env.SHOPIFY_FLAG_NO_COLOR) ||
env.TERM === 'dumb'
Expand Down
Loading