From f1dc1916a0a3b13a9ace369e8bf850cc03c8690c Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Fri, 17 Jan 2025 10:35:41 +0000 Subject: [PATCH] Build/Test Tools: Hide the Node.js error message when a Docker command produces a non-zero exit code. When running a command that goes via docker.js and produces a non-zero exit code, the error message and stack trace from node an safely be hidden because the stack trace only points to the `execSync()` call and is of no use. Fixes #62814 git-svn-id: https://develop.svn.wordpress.org/trunk@59659 602fd350-edb4-49c9-b593-d223f7449a82 --- tools/local-env/scripts/docker.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/local-env/scripts/docker.js b/tools/local-env/scripts/docker.js index daa6b88262..c1dc2b27e1 100644 --- a/tools/local-env/scripts/docker.js +++ b/tools/local-env/scripts/docker.js @@ -12,5 +12,10 @@ if (process.argv.includes('--coverage-html')) { process.env.LOCAL_PHP_XDEBUG_MODE = 'coverage'; } -// Execute any docker compose command passed to this script. -execSync( 'docker compose ' + composeFiles + ' ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } ); +// This try-catch prevents the superfluous Node.js debugging information from being shown if the command fails. +try { + // Execute any Docker compose command passed to this script. + execSync( 'docker compose ' + composeFiles + ' ' + process.argv.slice( 2 ).join( ' ' ), { stdio: 'inherit' } ); +} catch ( error ) { + process.exit( 1 ); +}