Skip to content

Commit 600ea2a

Browse files
committed
Add error handling to db reset and install commands in case environment is not started
1 parent 1fa7981 commit 600ea2a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tools/local-env/scripts/install.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,23 @@ const testConfig = readFileSync( 'wp-tests-config-sample.php', 'utf8' )
3636
writeFileSync( 'wp-tests-config.php', testConfig );
3737

3838
// Once the site is available, install WordPress!
39-
wait_on( { resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`] } )
39+
wait_on( {
40+
resources: [ `tcp:localhost:${process.env.LOCAL_PORT}`],
41+
timeout: 3000,
42+
} )
43+
.catch( err => {
44+
console.error( `Error: It appears the development environment has not been started. Message: ${ err.message }` );
45+
console.error( `Did you forget to do 'npm run env:start'?` );
46+
process.exit( 1 );
47+
} )
4048
.then( () => {
4149
wp_cli( 'db reset --yes' );
4250
const installCommand = process.env.LOCAL_MULTISITE === 'true' ? 'multisite-install' : 'install';
4351
wp_cli( `core ${ installCommand } --title="WordPress Develop" --admin_user=admin --admin_password=password [email protected] --skip-email --url=http://localhost:${process.env.LOCAL_PORT}` );
52+
} )
53+
.catch( err => {
54+
console.error( `Error: Unable to reset DB and install WordPress. Message: ${ err.message }` );
55+
process.exit( 1 );
4456
} );
4557

4658
/**

0 commit comments

Comments
 (0)