Conversation
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Adjust wp separator validation so it only applies when wp command payload arguments are present, not for option-only invocations like --help. Add regression coverage in command parser tests to ensure `vip wp --help` dispatches to the wp subcommand correctly.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR relaxes the vip wp separator (--) validation so that vip wp --help (and other option-only wp invocations) can dispatch to the vip-wp subcommand without forcing a separator, and adds a regression test to ensure the behavior stays correct.
Changes:
- Update
wpsubcommand validation to only require--when “wp command payload” arguments are detected. - Add a command parser test covering
vip wp --helpdispatching tovip-wp.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/lib/cli/command.js |
Adjusts wp separator enforcement by introducing hasWpCommandPayload logic. |
__tests__/lib/cli/command.js |
Adds regression coverage ensuring vip wp --help spawns the vip-wp script without requiring --. |
|
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
tests/lib/cli/command.js:82
- The new regression tests cover
vip wp --helpand a value-taking option (--path /tmp/wp), but they don’t cover the case where a boolean WP-CLI flag precedes a command payload (e.g.vip wp --quiet plugin list). With the currenthasWpCommandPayload()heuristic, those invocations can be misdetected as “option-only” and bypass the--separator requirement; adding an explicit test for this would prevent regressions.
it( 'allows wp option-only invocations without separator', async () => {
const parentScript = path.join( process.cwd(), 'src/bin/vip.js' );
const childScript = path.join( process.cwd(), 'src/bin/vip-wp.js' );
const cmd = command( { requiredArgs: 0 } ).command( 'wp', 'Run WP-CLI commands.' );
await cmd.argv( [ process.execPath, parentScript, 'wp', '--help' ] );
expect( spawnSync ).toHaveBeenCalledWith( process.execPath, [ childScript, '--help' ], {
stdio: 'inherit',
env: process.env,
} );
expect( process.exit ).toHaveBeenCalledWith( 0 );
} );
it( 'allows wp option-only invocations with option values without separator', async () => {
const parentScript = path.join( process.cwd(), 'src/bin/vip.js' );
const childScript = path.join( process.cwd(), 'src/bin/vip-wp.js' );
const cmd = command( { requiredArgs: 0 } ).command( 'wp', 'Run WP-CLI commands.' );
await cmd.argv( [ process.execPath, parentScript, 'wp', '--path', '/tmp/wp' ] );
expect( spawnSync ).toHaveBeenCalledWith(
process.execPath,
[ childScript, '--path', '/tmp/wp' ],
{
stdio: 'inherit',
env: process.env,
}
);
expect( process.exit ).toHaveBeenCalledWith( 0 );
} );
it( 'dispatches when child options appear before -- and subcommand follows separator', async () => {
const parentScript = path.join( process.cwd(), 'src/bin/vip.js' );
const childScript = path.join( process.cwd(), 'src/bin/vip-wp.js' );
const cmd = command( { requiredArgs: 0 } ).command( 'wp', 'Run WP-CLI commands.' );
rinatkhaziev
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adjust wp separator validation so it only applies when wp command payload arguments are present, not for option-only invocations like --help.
Add regression coverage in command parser tests to ensure
vip wp --helpdispatches to the wp subcommand correctly.