From ede5bf3c41609aee30870c2bc354f4c2e143c931 Mon Sep 17 00:00:00 2001 From: Naoki Ikeguchi Date: Thu, 3 Dec 2020 00:46:29 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20yarn.lock=20parser=20is=20?= =?UTF-8?q?not=20working=20properly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Scanner/Yarn/YarnLockParser.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Scanner/Yarn/YarnLockParser.php b/src/Scanner/Yarn/YarnLockParser.php index ce7b314..7059819 100644 --- a/src/Scanner/Yarn/YarnLockParser.php +++ b/src/Scanner/Yarn/YarnLockParser.php @@ -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), ); }