1 import { execSync } from 'child_process';
2 import { URL } from 'url';
3 import { commandAsWebserver } from '../globals';
6 * Logs in as the admin user.
8 * @param {function} callback
9 * A callback which will allow running commands as an administrator.
11 * The drupalLoginAsAdmin command.
13 exports.command = function drupalLoginAsAdmin(callback) {
15 this.drupalUserIsLoggedIn(sessionExists => {
19 const userLink = execSync(
21 `php ./scripts/test-site.php user-login 1 --site-path ${
27 this.drupalRelativeURL(userLink.toString());
29 this.drupalUserIsLoggedIn(sessionExists => {
31 throw new Error('Logging in as an admin user failed.');
36 if (typeof callback === 'function') {
40 this.drupalLogout({ silent: true });