-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated NpmRepository to skip broken versions #308
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
namespace Fxp\Composer\AssetPlugin\Repository; | ||
|
||
use Composer\DependencyResolver\Pool; | ||
use Composer\IO\IOInterface; | ||
use Composer\Package\CompletePackageInterface; | ||
use Composer\Package\Loader\ArrayLoader; | ||
use Composer\Repository\ArrayRepository; | ||
|
@@ -147,10 +148,19 @@ protected function createArrayRepositoryConfig(array $packageConfigs) | |
$loader = new ArrayLoader(); | ||
|
||
foreach ($packageConfigs as $version => $config) { | ||
$config['version'] = $version; | ||
$config = $this->assetType->getPackageConverter()->convert($config); | ||
$config = $this->assetRepositoryManager->solveResolutions($config); | ||
$packages[] = $loader->load($config); | ||
try { | ||
$config['version'] = $version; | ||
$config = $this->assetType->getPackageConverter()->convert($config); | ||
$config = $this->assetRepositoryManager->solveResolutions($config); | ||
$packages[] = $loader->load($config); | ||
} catch (\UnexpectedValueException $exception) { | ||
// Most probably version constraint is broken. | ||
// Skip this version and hope that another one will be OK | ||
$this->io->write("<warning>Skipped {$config['name']} version {$version}: {$exception->getMessage()}</warning>", IOInterface::VERBOSE); | ||
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
And it will be good for me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
the message says much less than the comment. should probably improve the message to say, why the version was skipped. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm for keeping the comment then, it does not hurt and provides more context. |
||
} catch (\Exception $exception) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This catch is unnecessary. |
||
throw $exception; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why catch it if you don't do anything with it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SilverFire See my previous review, because it is past in outdated status with your new update, but it's not the case: this catch is unnecessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also think this can be removed, you're just catching and throwing the exception again :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opps. It used id for debug to place breakpoint on |
||
} | ||
} | ||
|
||
return $packages; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a warning or notice, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, done