File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff 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( {
6766function 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+ }
You can’t perform that action at this time.
0 commit comments