Chris@17: import { execSync } from 'child_process'; Chris@17: import { URL } from 'url'; Chris@17: Chris@17: /** Chris@17: * Logs out from a Drupal site. Chris@17: * Chris@17: * @param {object} [settings={}] Chris@17: * The settings object. Chris@17: * @param {boolean} [settings.silent=false] Chris@17: * If the command should be run silently. Chris@17: * @param {function} callback Chris@17: * A callback which will be called, when the logout is finished. Chris@17: * @return {object} Chris@17: * The drupalLogout command. Chris@17: */ Chris@17: exports.command = function drupalLogout({ silent = false } = {}, callback) { Chris@17: const self = this; Chris@17: Chris@17: this.drupalRelativeURL('/user/logout'); Chris@17: Chris@17: this.drupalUserIsLoggedIn(sessionExists => { Chris@17: if (silent) { Chris@17: if (sessionExists) { Chris@17: throw new Error('Logging out failed.'); Chris@17: } Chris@17: } else { Chris@17: this.assert.equal(sessionExists, false, 'The user was logged out.'); Chris@17: } Chris@17: }); Chris@17: Chris@17: if (typeof callback === 'function') { Chris@17: callback.call(self); Chris@17: } Chris@17: Chris@17: return this; Chris@17: };