From 318b5cf90573282f25a6c8757e38b46f3707a60e Mon Sep 17 00:00:00 2001 From: Christopher Allford <6451942+ObliviousHarmony@users.noreply.github.com> Date: Thu, 18 May 2023 09:04:35 -0700 Subject: [PATCH] Replaced `beforeDestroy` With `afterDestroy` --- packages/env/CHANGELOG.md | 2 +- packages/env/README.md | 2 +- packages/env/lib/commands/destroy.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/env/CHANGELOG.md b/packages/env/CHANGELOG.md index 55621d228a6233..eb255e71ecf4df 100644 --- a/packages/env/CHANGELOG.md +++ b/packages/env/CHANGELOG.md @@ -8,7 +8,7 @@ ### New feature -- Add `afterStart`, `afterClean`, and `beforeDestroy` lifecycle scripts to a new `lifecycleScripts` key in `.wp-env.json`. +- Add `afterStart`, `afterClean`, and `afterDestroy` lifecycle scripts to a new `lifecycleScripts` key in `.wp-env.json`. - Add a series of `WP_ENV_LIFECYCLE_SCRIPT_` environment variables for the various lifecycle scripts. ### Enhancement diff --git a/packages/env/README.md b/packages/env/README.md index 38b108158a42f4..a4abacb0184f50 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -569,7 +569,7 @@ build won't break on subsequent executions. * `afterStart`: Runs after `wp-env start` has finished setting up the environment. * `afterClean`: Runs after `wp-env clean` has finished cleaning the environment. -* `beforeDestroy`: Runs before `wp-env destroy` begins destroying anything. +* `afterDestroy`: Runs after `wp-env destroy` has destroyed the environment. ## Examples diff --git a/packages/env/lib/commands/destroy.js b/packages/env/lib/commands/destroy.js index af4dc289d43204..fbbff0c8a28982 100644 --- a/packages/env/lib/commands/destroy.js +++ b/packages/env/lib/commands/destroy.js @@ -57,10 +57,6 @@ module.exports = async function destroy( { spinner, scripts, debug } ) { return; } - if ( scripts ) { - await executeLifecycleScript( 'beforeDestroy', config, spinner ); - } - spinner.text = 'Removing docker images, volumes, and networks.'; await dockerCompose.down( { @@ -76,5 +72,9 @@ module.exports = async function destroy( { spinner, scripts, debug } ) { await new Promise( ( resolve ) => setTimeout( resolve, 10000 ) ); await rimraf( config.workDirectoryPath ); + if ( scripts ) { + await executeLifecycleScript( 'afterDestroy', config, spinner ); + } + spinner.text = 'Removed WordPress environment.'; };