Skip to content

Commit

Permalink
Update FreezeVersionsCommand.php
Browse files Browse the repository at this point in the history
Change return
  • Loading branch information
MaximeCulea authored Jul 24, 2022
1 parent 5055b27 commit 9ba6ce8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/Command/FreezeVersionsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -27,29 +27,29 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
$composerFile = new JsonFile( $composerPath );
if ( ! $composerFile->exists() ) {
$output->writeln( "<error>Composer file not found.</error>" );
exit;
return 1;
}

// if we cannot write then bail
if ( ! is_writeable( $composerPath ) ) {
$output->writeln( "<error>The composer.json file cannot be rewritten!</error>" );
$output->writeln( "<error>Please check your file permissions.</error>" );
exit;
return 1;
}

$lockFile = new JsonFile( $lockPath );
if ( ! $lockFile->exists() ) {
$output->writeln( "<warning>No composer lock file found.</warning>" );
$output->writeln( "You need to run a composer update once before using this command." );
exit;
return 1;
}

try {
$composerJson = $composerFile->read();
$lockJson = $lockFile->read();
if ( ! isset( $lockJson['packages'] ) || ! isset( $lockJson['packages-dev'] ) ) {
$output->writeln( "<warning>Your lock file does not contain any packages.<warning>" );
exit;
return 1;
}

if ( isset( $composerJson['require'] ) ) {
Expand Down Expand Up @@ -77,7 +77,10 @@ protected function execute( InputInterface $input, OutputInterface $output ) {
} catch( RuntimeException $e ) {
$output->writeln( "<error>An error occurred</error>" );
$output->writeln( sprintf( "<error>%s</error>", $e->getMessage() ) );
exit;
return 1;
}

// All worked as excepted
return 0;
}
}
}

0 comments on commit 9ba6ce8

Please sign in to comment.