Skip to content

Commit

Permalink
fix: packages-json weird format
Browse files Browse the repository at this point in the history
  • Loading branch information
SRWieZ committed Dec 24, 2024
1 parent 17ca8c6 commit de0504e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/whatsdiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ function extractComposerPackagesVersions($composerLockContent): array
->toArray();
}

function extractNpmjsPackagesVersions($composerLockContent): array
function extractNpmjsPackagesVersions($packageLockContent): array
{
return collect($composerLockContent['packages'] ?? [])
return collect($packageLockContent['packages'] ?? [])
->filter(fn ($package, $key) => ! empty($key) && ! empty($package['version'])) // package-lock.json is weird
->mapWithKeys(fn ($package, $key) => [
str_replace('node_modules/', '', $key) => $package['version'],
])
Expand Down Expand Up @@ -231,7 +232,7 @@ function diffPackageLockPackages($last, $previous)
function printDiff(array $diff, $type = 'composer'): void
{
if (! count($diff)) {
echo ' → No changes detected'.PHP_EOL;
echo ' → No dependencies changes detected'.PHP_EOL;

return;
}
Expand Down

0 comments on commit de0504e

Please sign in to comment.