Skip to content

Commit

Permalink
fix(misc): prevent --quiet and --verbose from both being true (#15836)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder authored Mar 23, 2023
1 parent 7a48214 commit 7d61ae2
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 22 deletions.
2 changes: 0 additions & 2 deletions docs/generated/cli/affected.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ Untracked changes

Type: `boolean`

Default: `false`

Prints additional information about the commands (e.g., stack traces)

### version
Expand Down
2 changes: 0 additions & 2 deletions docs/generated/cli/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ Rerun the tasks even when the results are available in the cache

Type: `boolean`

Default: `false`

Prints additional information about the commands (e.g., stack traces)

### version
Expand Down
2 changes: 0 additions & 2 deletions docs/generated/cli/run-many.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ Tasks to run for affected projects

Type: `boolean`

Default: `false`

Prints additional information about the commands (e.g., stack traces)

### version
Expand Down
2 changes: 0 additions & 2 deletions docs/generated/packages/nx/documents/affected.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ Untracked changes

Type: `boolean`

Default: `false`

Prints additional information about the commands (e.g., stack traces)

### version
Expand Down
2 changes: 0 additions & 2 deletions docs/generated/packages/nx/documents/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ Rerun the tasks even when the results are available in the cache

Type: `boolean`

Default: `false`

Prints additional information about the commands (e.g., stack traces)

### version
Expand Down
2 changes: 0 additions & 2 deletions docs/generated/packages/nx/documents/run-many.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ Tasks to run for affected projects

Type: `boolean`

Default: `false`

Prints additional information about the commands (e.g., stack traces)

### version
Expand Down
4 changes: 3 additions & 1 deletion e2e/nx-misc/src/extras.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ describe('Extra Nx Misc Tests', () => {

describe('generate --quiet', () => {
it('should not log tree operations or install tasks', () => {
const output = runCLI('generate @nrwl/react:app --quiet test-project');
const output = runCLI('generate @nrwl/react:app --quiet test-project', {
verbose: false,
});
expect(output).not.toContain('CREATE');
expect(output).not.toContain('Installed');
});
Expand Down
12 changes: 8 additions & 4 deletions e2e/utils/command-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface RunCmdOpts {
env?: Record<string, string | undefined>;
cwd?: string;
silent?: boolean;
verbose?: boolean;
}

/**
Expand Down Expand Up @@ -295,7 +296,7 @@ export function runNgAdd(

const r = stripConsoleColors(result);

if (isVerboseE2ERun()) {
if (opts.verbose ?? isVerboseE2ERun()) {
output.log({
title: `Original command: ${fullCommand}`,
bodyLines: [result as string],
Expand All @@ -319,12 +320,15 @@ export function runCLI(
opts: RunCmdOpts = {
silenceError: false,
env: undefined,
verbose: undefined,
}
): string {
try {
const pm = getPackageManagerCommand();
const logs = execSync(
`${pm.runNx} ${command} ${isVerboseE2ERun() ? ' --verbose' : ''}`,
`${pm.runNx} ${command} ${
opts.verbose ?? isVerboseE2ERun() ? ' --verbose' : ''
}`,
{
cwd: opts.cwd || tmpProjPath(),
env: {
Expand All @@ -338,7 +342,7 @@ export function runCLI(
}
);

if (isVerboseE2ERun()) {
if (opts.verbose ?? isVerboseE2ERun()) {
output.log({
title: `Original command: ${command}`,
bodyLines: [logs as string],
Expand Down Expand Up @@ -384,7 +388,7 @@ export function runLernaCLI(
maxBuffer: 50 * 1024 * 1024,
});

if (isVerboseE2ERun()) {
if (opts.verbose ?? isVerboseE2ERun()) {
output.log({
title: `Original command: ${fullCommand}`,
bodyLines: [logs as string],
Expand Down
7 changes: 5 additions & 2 deletions packages/create-nx-workspace/src/create-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function createPreset<T extends CreateWorkspaceOptions>(
): Promise<void> {
const { skipGit, ci, commit, nxCloud, ...restArgs } = parsedArgs;

const args = unparse({
let args = unparse({
...restArgs,
}).join(' ');

Expand All @@ -38,7 +38,10 @@ export async function createPreset<T extends CreateWorkspaceOptions>(
}
}

const command = `g ${preset}:preset --quiet ${args}`;
if (process.env.NX_VERBOSE_LOGGING !== 'true') {
args = '--quiet ' + args;
}
const command = `g ${preset}:preset ${args}`;

try {
const [exec, ...args] = pmc.exec.split(' ');
Expand Down
4 changes: 1 addition & 3 deletions packages/nx/src/command-line/nx-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ function withRunOptions(yargs: yargs.Argv): yargs.Argv {
type: 'boolean',
describe:
'Prints additional information about the commands (e.g., stack traces)',
default: false,
})
.option('nx-bail', {
describe: 'Stop command execution after the first failed task',
Expand Down Expand Up @@ -752,12 +751,11 @@ function withGenerateOptions(yargs: yargs.Argv) {
describe:
'Prints additional information about the commands (e.g., stack traces)',
type: 'boolean',
default: false,
})
.option('quiet', {
describe: 'Hides logs from tree operations (e.g. `CREATE package.json`)',
type: 'boolean',
default: false,
conflicts: ['verbose'],
})
.middleware((args) => {
if (process.env.NX_INTERACTIVE === 'false') {
Expand Down

1 comment on commit 7d61ae2

@vercel
Copy link

@vercel vercel bot commented on 7d61ae2 Mar 23, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.