Skip to content

Fail closed when an unsupported lockfile changes - #136

Open
oalders wants to merge 2 commits into
mainfrom
fix-133
Open

oalders wants to merge 2 commits into
mainfrom
fix-133

Conversation

@oalders

@oalders oalders commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Closes #133

Changes

  • bin/diff-lockfiles.js: changed files whose basename is pnpm-lock.yaml, yarn.lock, bun.lock, bun.lockb, or npm-shrinkwrap.json (any directory) are reported on stderr as Unsupported lockfile changed, not diffed: <path>.
    • With --fail-on-downgrade, any such change exits 1, taking precedence over 2.
    • Without the flag the exit code is unchanged (0), and stdout is identical either way.
  • git diff --name-only now uses -z (NUL-delimited). Without it, git C-quotes non-ASCII paths (e.g. "caf\303\251/yarn.lock"), so both the new check and the existing package-lock.json filter silently missed them (fail-open).
  • README.md and CLAUDE.md document the new exit-code behaviour.

Testing

  • New CLI tests: an unsupported lockfile in a subdirectory, with and without the flag; a non-ASCII directory; a downgrade plus an unsupported lockfile together (exit 1, identical stdout with and without the flag).
  • All 4 new tests fail against the base bin/diff-lockfiles.js and pass with the fix.
  • npm test: 37/37 pass. npm run lint: clean.

Declined findings

  • Table-driven test over all five names: it would only re-assert the constant set.
  • Anchoring /package-lock\.json$/: pre-existing; commit 84d480e chose "ends with" on purpose.
  • --no-renames, case-insensitive or glob matching, adding deno.lock: no real producer of those cases; the list matches the issue scope.
  • Escaping filenames in the stderr warning: the exit code that drives the gate is unaffected, and a PR author who controls paths can already print arbitrary CI log lines.
  • Mentioning exit 1 in the --help text: the README exit-code table documents it, and reviewers disagreed with each other on this.
  • Further CLAUDE.md rewording (re-splitting the exit-code clause, dropping the -z note): already addressed in round 1; the -z note guards against removing it.
  • Windows path separators in tests: CI runs only on ubuntu-latest.

🤖 Generated with Claude Code · Opus 5.5

oalders and others added 2 commits October 8, 2026 00:57
Warn on stderr for changed pnpm/yarn/bun/shrinkwrap lockfiles (matched by
basename) and exit 1 under --fail-on-downgrade, since they can't be verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@oalders
oalders marked this pull request as ready for review October 8, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail closed when an unsupported lockfile changes

1 participant