fix(core): prioritize --output-style flag over tui env vars (#30969)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
e5dc244e66
commit
95652aef88
@ -112,4 +112,30 @@ describe('shouldUseTui', () => {
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
describe('priority', () => {
|
||||
it('should prioritize the CLI args over the env var', () =>
|
||||
withEnvironmentVariables(
|
||||
{
|
||||
NX_TUI: 'false',
|
||||
CI: 'false',
|
||||
},
|
||||
() => {
|
||||
expect(shouldUseTui({}, { outputStyle: 'dynamic' }, true)).toBe(true);
|
||||
}
|
||||
));
|
||||
|
||||
it('should prioritize the env var over the nx.json config', () =>
|
||||
withEnvironmentVariables(
|
||||
{
|
||||
NX_TUI: 'false',
|
||||
CI: 'false',
|
||||
},
|
||||
() => {
|
||||
expect(shouldUseTui({ tui: { enabled: true } }, {}, true)).toBe(
|
||||
false
|
||||
);
|
||||
}
|
||||
));
|
||||
});
|
||||
});
|
||||
|
||||
@ -2,6 +2,7 @@ import type { NxJsonConfiguration } from '../config/nx-json';
|
||||
import { IS_WASM } from '../native';
|
||||
import { NxArgs } from '../utils/command-line-utils';
|
||||
import { isCI } from '../utils/is-ci';
|
||||
import { logger } from '../utils/logger';
|
||||
|
||||
let tuiEnabled = undefined;
|
||||
|
||||
@ -36,16 +37,26 @@ export function shouldUseTui(
|
||||
return false;
|
||||
}
|
||||
|
||||
// The environment variable takes precedence over the nx.json config
|
||||
if (typeof process.env.NX_TUI === 'string') {
|
||||
return process.env.NX_TUI === 'true';
|
||||
}
|
||||
|
||||
if (['static', 'stream', 'dynamic-legacy'].includes(nxArgs.outputStyle)) {
|
||||
// If the user has specified a non-TUI output style, we disable the TUI
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nxArgs.outputStyle === 'dynamic' || nxArgs.outputStyle === 'tui') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// The environment variable takes precedence over the nx.json config, but
|
||||
// are lower priority than the CLI args as they are less likely to change
|
||||
// between runs, whereas the CLI args are specified by the user for each run.
|
||||
if (typeof process.env.NX_TUI === 'string') {
|
||||
return process.env.NX_TUI === 'true';
|
||||
}
|
||||
|
||||
// BELOW THIS LINE ARE "repo specific" checks, instead of "user specific" checks.
|
||||
// "user specific" checks are specified by the current user rather than the repo
|
||||
// settings which are applied for all users of the repo... so they are more specific
|
||||
// and take priority.
|
||||
if (
|
||||
// Interactive TUI doesn't make sense on CI
|
||||
isCI() ||
|
||||
@ -58,10 +69,6 @@ export function shouldUseTui(
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nxArgs.outputStyle === 'dynamic' || nxArgs.outputStyle === 'tui') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Respect user config
|
||||
if (typeof nxJson.tui?.enabled === 'boolean') {
|
||||
return Boolean(nxJson.tui?.enabled);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user