File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 3737 run : |
3838 npm --version
3939
40+ # Save the current top-level dependencies from package-lock.json
41+ node -e "console.log(JSON.stringify(require('./package-lock.json').packages['']))" > /tmp/before.json
42+
4043 # From https://docs.npmjs.com/cli/v7/commands/npm-install
4144 #
4245 # The --package-lock-only argument will only update the
4548 #
4649 npm install --package-lock-only --ignore-scripts --include=optional
4750
48- # If the package.json (dependencies and devDependencies) is
49- # in correct sync with package-lock.json running the above command
50- # should *not* make an edit to the package-lock.json. I.e.
51- # running `git status` should
52- # say "nothing to commit, working tree clean".
53- git diff --exit-code
51+ # Extract the top-level dependencies after regeneration
52+ node -e "console.log(JSON.stringify(require('./package-lock.json').packages['']))" > /tmp/after.json
53+
54+ # Compare only the top-level package dependencies
55+ # This ignores platform-specific differences in nested dependency resolution
56+ # (like "peer" flags) that don't affect actual installed versions
57+ if ! diff /tmp/before.json /tmp/after.json; then
58+ echo "ERROR: Top-level dependencies in package-lock.json are out of sync with package.json"
59+ echo "Please run 'npm install' locally and commit the updated package-lock.json"
60+ exit 1
61+ fi
62+
63+ echo "✓ Top-level dependencies are in sync"
You can’t perform that action at this time.
0 commit comments