From 852dc9d666325f714b2f16cc4c069cecc238de3d Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 31 Aug 2020 08:50:11 +0100 Subject: [PATCH] Fix error handling for performance tests on CI --- bin/plugin/cli.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/plugin/cli.js b/bin/plugin/cli.js index dc3a8cf65e6204..054199ef4b4b10 100755 --- a/bin/plugin/cli.js +++ b/bin/plugin/cli.js @@ -5,6 +5,17 @@ */ const program = require( 'commander' ); +const catchException = ( command ) => { + return async ( ...args ) => { + try { + await command( ...args ); + } catch ( error ) { + console.error( error ); + process.exitCode = 1; + } + }; +}; + /** * Internal dependencies */ @@ -22,13 +33,13 @@ program .description( 'Release an RC version of the plugin (supports only rc.1 for now)' ) - .action( releaseRC ); + .action( catchException( releaseRC ) ); program .command( 'release-plugin-stable' ) .alias( 'stable' ) .description( 'Release a stable version of the plugin' ) - .action( releaseStable ); + .action( catchException( releaseStable ) ); program .command( 'prepare-packages-stable' ) @@ -36,7 +47,7 @@ program .description( 'Prepares the packages to be published to npm as stable (latest dist-tag, production version)' ) - .action( prepareLatestDistTag ); + .action( catchException( prepareLatestDistTag ) ); program .command( 'prepare-packages-rc' ) @@ -44,7 +55,7 @@ program .description( 'Prepares the packages to be published to npm as RC (next dist-tag, RC version)' ) - .action( prepareNextDistTag ); + .action( catchException( prepareNextDistTag ) ); program .command( 'release-plugin-changelog' ) @@ -52,7 +63,7 @@ program .option( '-m, --milestone ', 'Milestone' ) .option( '-t, --token ', 'Github token' ) .description( 'Generates a changelog from merged Pull Requests' ) - .action( getReleaseChangelog ); + .action( catchException( getReleaseChangelog ) ); program .command( 'performance-tests [branches...]' ) @@ -65,6 +76,6 @@ program .description( 'Runs performance tests on two separate branches and outputs the result' ) - .action( runPerformanceTests ); + .action( catchException( runPerformanceTests ) ); program.parse( process.argv );