fix: make CHANGELOG files respect .npmignore settings

CHANGELOG files should obey .npmignore directives like any other file. 
Previously, CHANGELOG files were being unconditionally included in packages, 
even when listed in .npmignore, which is inconsistent with npm's behavior.

This change removes the special treatment of CHANGELOG files so they can be 
properly ignored when listed in .npmignore.

Fixes #18691

Co-authored-by: Electroid <Electroid@users.noreply.github.com>

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>"
This commit is contained in:
claude[bot]
2025-05-19 19:18:33 +00:00
committed by GitHub
parent 457c15e424
commit 91c065d8c8
2 changed files with 2 additions and 5 deletions

View File

@@ -1066,7 +1066,7 @@ pub const PackCommand = struct {
if (dir_depth == 1) {
// first, check files that can never be ignored. project root
// directory only
if (isUnconditionallyIncludedFile(entry_name) or isSpecialFileOrVariant(entry_name, "CHANGELOG")) {
if (isUnconditionallyIncludedFile(entry_name)) {
return null;
}

View File

@@ -931,7 +931,7 @@ describe("files", () => {
]);
});
test(".npmignore cannot exclude CHANGELOG", async () => {
test(".npmignore can exclude CHANGELOG", async () => {
await Promise.all([
write(
join(packageDir, "package.json"),
@@ -949,9 +949,6 @@ describe("files", () => {
const tarball = readTarball(join(packageDir, "pack-files-changelog-1.1.2.tgz"));
expect(tarball.entries).toMatchObject([
{ "pathname": "package/package.json" },
{ "pathname": "package/CHANGELOG" },
{ "pathname": "package/CHANGELOG.md" },
{ "pathname": "package/CHANGELOG.txt" },
]);
});