Skip to content

fix(github): write package.json and package-lock.json with a trailing newline when bumping the version - #53

Open
bwp91 wants to merge 2 commits into
latestfrom
fix-version-script-trailing-newline
Open

fix(github): write package.json and package-lock.json with a trailing newline when bumping the version#53
bwp91 wants to merge 2 commits into
latestfrom
fix-version-script-trailing-newline

Conversation

@bwp91

@bwp91 bwp91 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The release version-bump scripts write both manifests with JSON.stringify, which does not end with a newline. npm writes both files with one, so the file the workflow leaves behind differs from the file in the repo by a missing final newline.

That is enough to break a release. In a repo whose prepublishOnly runs lint over the whole tree, eslint reaches the rewritten package.json and fails:

package.json
  69:2  error  Newline required at end of file but not found  style/eol-last
✖ 1 problem (1 error, 0 warnings)

Both august-yale and rainbird failed this way on 2 August. Build, lint and the GitHub release step all passed and only publish failed, so no tag or release was created and nothing reached npm — the releases simply did not happen.

All four scripts that bump a version had it, so all four are fixed, for package-lock.json as well as package.json:

  • .github/npm-version-script-esm.js — the one the current release.yml downloads and runs
  • .github/npm-version-script.js
  • .github/scripts/npm-version-script-esm-auto.js
  • .github/scripts/npm-version-script-auto.cjs

Verified by running the patched scripts against a real checkout rather than by inspection: the version bumps exactly as before, both files come out ending in a newline and still parse as JSON, and the resulting package.json passes the same eslint --max-warnings=0 that rejected it in CI.

Only repos that lint their whole tree during prepublishOnly were affected. The plugins keep their version in the repo and do not run these scripts on a stable release.

🤖 Generated with Claude Code

Copilot AI left a comment

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.

Pull request overview

This PR fixes the Homebridge organization’s npm release version-bump scripts so that rewritten package.json and package-lock.json end with a trailing newline, matching npm’s output and avoiding eol-last lint failures that can break prepublishOnly publish steps.

Changes:

  • Update all version-bump scripts to write package.json with a final \n.
  • Update all version-bump scripts to write package-lock.json with a final \n.
  • Add inline comments explaining why the newline is required (eslint eol-last compatibility).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
.github/scripts/npm-version-script-esm-auto.js Writes both manifests with a trailing newline after version updates.
.github/scripts/npm-version-script-auto.cjs Writes both manifests with a trailing newline after version updates.
.github/npm-version-script.js Writes both manifests with a trailing newline after version updates.
.github/npm-version-script-esm.js Writes both manifests with a trailing newline after version updates.

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.

2 participants