Skip to content

Lockfile trailing newline fix and normalization for frozen lockfile comparison#1196

Open
brooke-hamilton wants to merge 3 commits intodevcontainers:mainfrom
brooke-hamilton:newline-fix
Open

Lockfile trailing newline fix and normalization for frozen lockfile comparison#1196
brooke-hamilton wants to merge 3 commits intodevcontainers:mainfrom
brooke-hamilton:newline-fix

Conversation

@brooke-hamilton
Copy link
Copy Markdown
Contributor

Summary

Fixes lockfile handling to ensure trailing newlines and normalize formatting when comparing lockfiles in frozen mode.

Fixes #1008

Changes

  • Trailing newline: Lockfiles now always end with a trailing newline per POSIX convention
  • Frozen lockfile comparison: Normalizes existing lockfile content through JSON.parse → JSON.stringify before comparing, so cosmetic formatting differences (indentation, trailing whitespace, missing newline) don't cause false mismatches in frozen mode
  • Added comments: Explanatory comments for the POSIX newline convention and normalization logic

Modified Files

  • src/spec-configuration/lockfile.ts - Core lockfile logic with newline and normalization fixes
  • src/test/container-features/lockfile.test.ts - New tests for:
    • Lockfile ends with trailing newline
    • Frozen lockfile matches despite formatting differences
    • Frozen lockfile fails when lockfile does not exist
    • Corrupt lockfile causes build error
    • No lockfile flags with no existing lockfile is a no-op
  • Test fixture updates to include trailing newlines in expected lockfiles
  • New test fixture lockfile-frozen-no-lockfile for missing lockfile test

Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
Signed-off-by: Brooke Hamilton <45323234+brooke-hamilton@users.noreply.github.com>
@brooke-hamilton brooke-hamilton requested a review from a team as a code owner April 9, 2026 01:31
"compilerOptions": {
"resolveJsonModule": true
"resolveJsonModule": true,
"types": ["node", "mocha"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Indentation

]
},
"mochaExplorer.files": "test/**/*.test.ts",
"mochaExplorer.files": "src/test/**/*.test.ts",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why does this change?

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.

Add newline at EOF to devcontainer-lock.json

2 participants