fix(core): running just 'nx' should show help (#26871)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior Running `nx` errors ## Expected Behavior `nx` show's help ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
51f5fe4434
commit
facfc147f8
@ -334,6 +334,12 @@ describe('Nx Commands', () => {
|
||||
}
|
||||
}, 300000);
|
||||
});
|
||||
|
||||
it('should show help if no command provided', () => {
|
||||
const output = runCLI('', { silenceError: true });
|
||||
expect(output).toContain('Smart Monorepos · Fast CI');
|
||||
expect(output).toContain('Commands:');
|
||||
});
|
||||
});
|
||||
|
||||
// TODO(colum): Change the fetcher to allow incremental migrations over multiple versions, allowing for beforeAll
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { CommandModule } from 'yargs';
|
||||
import { CommandModule, showHelp } from 'yargs';
|
||||
import {
|
||||
withBatch,
|
||||
withOverrides,
|
||||
@ -40,6 +40,11 @@ export const yargsNxInfixCommand: CommandModule = {
|
||||
const exitCode = await handleErrors(
|
||||
(args.verbose as boolean) ?? process.env.NX_VERBOSE_LOGGING === 'true',
|
||||
async () => {
|
||||
// Yargs parses <target> as 'undefined' if running just 'nx'
|
||||
if (!args.target || args.target === 'undefined') {
|
||||
showHelp();
|
||||
process.exit(1);
|
||||
}
|
||||
return (await import('./run-one')).runOne(
|
||||
process.cwd(),
|
||||
withOverrides(args, 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user