Skip to content

Commit

Permalink
Merge pull request #50 from bigbite/release/0.8.1
Browse files Browse the repository at this point in the history
Make sure uploads folder is writeable and cleared per soft reset
Allow switchUser command to be loggedout user
  • Loading branch information
jasonagnew authored Jan 12, 2021
2 parents 0a55225 + 9d206b7 commit 22c0c1f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bigbite/wp-cypress",
"version": "0.8.0",
"version": "0.8.1",
"description": "WordPress end to end testing with Cypress.io",
"repository": "https://github.com/bigbite/wp-cypress",
"author": {
Expand Down
16 changes: 11 additions & 5 deletions plugin/src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ public function add_user_command(): void {
* @return void
*/
public function set_user( $args ): void {
$user = get_user_by( 'login', $args[0] );
$user_id = 'false';

if ( ! $user ) {
WP_CLI::error( "User {$args[0]} doesn't exits." );
return;
if ( 'loggedout' !== $args[0] ) {
$user = get_user_by( 'login', $args[0] );

if ( ! $user ) {
WP_CLI::error( "User {$args[0]} doesn't exits." );
return;
}

$user_id = $user->ID;
}

file_put_contents( get_home_path() . '.userid', $user->ID );
file_put_contents( get_home_path() . '.userid', $user_id );

WP_CLI::success( 'Current User set to ' . $args[0] );
}
Expand Down
3 changes: 3 additions & 0 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ HARD_RESET=$2
shopt -s extglob
rm -rf !(wp-config.php|wp-cypress-config.php|seeds|wp-content|update.sh|.htaccess)

# Ensure uploads work
if ${HARD_RESET}; then rm -rf /var/www/html/wp-content/uploads && mkdir -p /var/www/html/wp-content/uploads && chmod -R 777 /var/www/html/wp-content/uploads; fi

if ${HARD_RESET}; then rm wp-config.php; fi

cp -rfp ../${VERSION}/* ./
Expand Down

0 comments on commit 22c0c1f

Please sign in to comment.