DEV Community

Bob Matcuk
Bob Matcuk

Posted on

1 1

Comparing package-lock Changes

I recently updated some dependencies in a node project and some things broke. I wanted to get a list of every dependency (and dependencies of dependencies) that changed, so I came up with this little one-liner.

You'll see that I'm passing two "files" into diff via I/O redirection. I'm using git to retrieve the two files - the commit that updated the dependencies had a git hash of 735e8cd3c. So, the first file is 735e8cd3c^:package-lock.json (notice the caret - that means the parent commit of 735e8cd3c - ie, the version before I updated dependencies). The second file is 735e8cd3c:package-lock.json (no caret - ie, the version where I updated dependencies).

I then pipe each file into jq (jq '.dependencies | map_values(.version)') to extract the name and version of every package my project depends on (that includes dependencies of dependencies).

Finally, diff will tell me what changed.

diff <(git show 735e8cd3c^:package-lock.json | jq '.dependencies | map_values(.version)') <(git show 735e8cd3c:package-lock.json | jq '.dependencies | map_values(.version)')
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more