Skip to content

Commit

Permalink
Merge pull request #51 from siketyan/fix-yarn-parser
Browse files Browse the repository at this point in the history
🐛 Fix yarn.lock parser is not working properly
  • Loading branch information
siketyan authored Dec 2, 2020
2 parents 2ff4edd + ede5bf3 commit fe7c22d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Scanner/Yarn/YarnLockParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ public function parse(?string $lock): DependencyCollection
$dependencies = [];

foreach ($packages as $names => $package) {
$version = $package['version'];

foreach (explode(',', $names) as $name) {
$name = substr($name, 0, strrpos($name, '@', -1));
$version = $package['version'];
$package = $this->packagePool->get($name);
$pkg = $this->packagePool->get($name);

if ($package === null) {
$package = new Package($name);
$this->packagePool->add($package);
if ($pkg === null) {
$pkg = new Package($name);
$this->packagePool->add($pkg);
}

$dependencies[] = new Dependency(
$package,
$pkg,
$this->versionParser->parse($version),
);
}
Expand Down

0 comments on commit fe7c22d

Please sign in to comment.