From 9ba6ce815423aadf258632b0a58fbac06e8c9c43 Mon Sep 17 00:00:00 2001 From: Maxime CULEA Date: Sun, 24 Jul 2022 15:34:38 +0200 Subject: [PATCH] Update FreezeVersionsCommand.php Change return --- src/Command/FreezeVersionsCommand.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Command/FreezeVersionsCommand.php b/src/Command/FreezeVersionsCommand.php index 9674735..12bd6cd 100644 --- a/src/Command/FreezeVersionsCommand.php +++ b/src/Command/FreezeVersionsCommand.php @@ -18,7 +18,7 @@ protected function execute( InputInterface $input, OutputInterface $output ) { // what is the command's purpose if ( false === $io->askConfirmation( "Do you really want to freeze all dependencies versions? [y|n]", true ) ) { - exit; + return 0; } $composerPath = $composer->getConfig()->getConfigSource()->getName(); @@ -27,21 +27,21 @@ protected function execute( InputInterface $input, OutputInterface $output ) { $composerFile = new JsonFile( $composerPath ); if ( ! $composerFile->exists() ) { $output->writeln( "Composer file not found." ); - exit; + return 1; } // if we cannot write then bail if ( ! is_writeable( $composerPath ) ) { $output->writeln( "The composer.json file cannot be rewritten!" ); $output->writeln( "Please check your file permissions." ); - exit; + return 1; } $lockFile = new JsonFile( $lockPath ); if ( ! $lockFile->exists() ) { $output->writeln( "No composer lock file found." ); $output->writeln( "You need to run a composer update once before using this command." ); - exit; + return 1; } try { @@ -49,7 +49,7 @@ protected function execute( InputInterface $input, OutputInterface $output ) { $lockJson = $lockFile->read(); if ( ! isset( $lockJson['packages'] ) || ! isset( $lockJson['packages-dev'] ) ) { $output->writeln( "Your lock file does not contain any packages." ); - exit; + return 1; } if ( isset( $composerJson['require'] ) ) { @@ -77,7 +77,10 @@ protected function execute( InputInterface $input, OutputInterface $output ) { } catch( RuntimeException $e ) { $output->writeln( "An error occurred" ); $output->writeln( sprintf( "%s", $e->getMessage() ) ); - exit; + return 1; } + + // All worked as excepted + return 0; } -} \ No newline at end of file +}