Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions drush.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@ Cypress.Commands.add('drush', (command, options = {}) => {

let exec_command = '';

const isBackground = options.background === true;
const suffix = isBackground ? ' &' : '';

if (Cypress.env('DRUSH_IS_DOCKSAL')) {
exec_command = 'fin drush ' + command;
exec_command = 'fin drush ' + command + suffix;
}

if (Cypress.env('DRUSH_IS_LANDO')) {
exec_command = 'lando drush ' + command;
exec_command = 'lando drush ' + command + suffix;
}

if (Cypress.env('DRUSH_IS_DDEV')) {
exec_command = 'ddev drush ' + command;
exec_command = 'ddev drush ' + command + suffix;
}

// In the format of PANTHEON_SITE_ID.ENVIRONMENT_ID
if(Cypress.env('DRUSH_IS_PANTHEON')) {
// Passing URI as well because drush will return HTTP links by default and not HTTPS which can cause tests to fail.
exec_command = 'ssh -T ' + Cypress.env('DRUSH_IS_PANTHEON') + '@appserver.' + Cypress.env('DRUSH_IS_PANTHEON') + '.drush.in -p 2222 -o "StrictHostKeyChecking=no" -o "AddressFamily inet" "drush --uri=' + Cypress.config('baseUrl') + ' ' + command + '"';
exec_command = 'ssh -T ' + Cypress.env('DRUSH_IS_PANTHEON') +
'@appserver.' + Cypress.env('DRUSH_IS_PANTHEON') + '.drush.in -p 2222 ' +
'-o "StrictHostKeyChecking=no" -o "AddressFamily inet" ' +
`"drush --uri=${Cypress.env('CYPRESS_BASE_URL')} ${command}${suffix}"`;
}

cy.exec(exec_command, options).then((result) => {
cy.exec(exec_command, { ...options, failOnNonZeroExit: false }).then((result) => {
cy.log(result.stdout);
cy.wrap(result.stdout).as('drushOutput');
})
Expand Down