Skip to content

Commit

Permalink
Fix wp-cli command.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Jun 30, 2024
1 parent c48b753 commit 633ddee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/commands/wp-cli-eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const wpCliEval = (command: string): void => {

// which is read from it's proper location in the plugins directory
cy.exec(
`npm --silent run env run tests-cli "eval-file wp-content/plugins/${pluginName}/${fileName}"` // eslint-disable-line @typescript-eslint/restrict-template-expressions
`npm --silent run env run tests-cli -- wp eval-file wp-content/plugins/${pluginName}/${fileName}` // eslint-disable-line @typescript-eslint/restrict-template-expressions
).then(result => {
cy.exec(`rm ${fileName}`);
cy.wrap(result);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/wp-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* ```
*/
export const wpCli = (command: string, ignoreFailures = false): void => {
const escapedCommand = command.replace(/"/g, '\\"').replace(/^wp /, '');
const escapedCommand = command.replace(/"/g, '\\"');

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
const options = {
failOnNonZeroExit: !ignoreFailures,
};
cy.exec(
`npm --silent run env run tests-cli "${escapedCommand}"`,
`npm --silent run env run tests-cli -- ${escapedCommand}`,
options
).then(result => {
cy.wrap(result);
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/e2e/wp-cli.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Command: wpCli', () => {
it('Should run cli command and receive the response', () => {
cy.wpCli('cli version')
cy.wpCli('wp cli version')
.its('stdout')
.should('match', /^WP-CLI \d+\.\d+/);
});
Expand Down

0 comments on commit 633ddee

Please sign in to comment.