Skip to content

Commit 9d15bb9

Browse files
committed
hacky hack hyck
1 parent 8cdfcfe commit 9d15bb9

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tools/local-env/scripts/install.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ wait_on( {
4949
process.exit( 1 );
5050
} )
5151
.then( () => {
52-
wp_cli( 'db check' );
53-
wp_cli( 'db reset --yes' );
52+
wp_cli_retry( 'db reset --yes' );
5453
const installCommand = process.env.LOCAL_MULTISITE === 'true' ? 'multisite-install' : 'install';
5554
wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
5655
} )
@@ -67,3 +66,18 @@ wait_on( {
6766
function wp_cli( cmd ) {
6867
execSync( `npm --silent run env:cli -- ${cmd} --path=/var/www/${process.env.LOCAL_DIR}`, { stdio: 'inherit' } );
6968
}
69+
70+
function wp_cli_retry( cmd, retries = 5 ) {
71+
try {
72+
wp_cli( cmd );
73+
} catch ( e ) {
74+
if ( retries > 0 ) {
75+
console.warn( `Retrying command "${cmd}" (${retries} retries left)...` );
76+
// Wait a bit before retrying.
77+
setTimeout( () => {}, 1000 );
78+
wp_cli_retry( cmd, retries - 1 );
79+
} else {
80+
throw e;
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)