Skip to content

Commit

Permalink
fix(pack): don't automatically include CHANGELOG when files is po…
Browse files Browse the repository at this point in the history
…pulated (#13789)
  • Loading branch information
dylan-conway authored Sep 8, 2024
1 parent 09fb2d1 commit 50d2f76
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/cli/pack_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,7 @@ pub const PackCommand = struct {
eql(entry_name, "LICENSE") or
eql(entry_name, "LICENCE") or
eql(entry_name, "README") or
entry_name.len > "README.".len and eql(entry_name[0.."README.".len], "README.") or
eql(entry_name, "CHANGELOG") or
entry_name.len > "CHANGELOG.".len and eql(entry_name[0.."CHANGELOG.".len], "CHANGELOG.")))
entry_name.len > "README.".len and eql(entry_name[0.."README.".len], "README.")))
included = true;
}

Expand Down
43 changes: 43 additions & 0 deletions test/cli/install/bun-pack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,49 @@ describe("bundledDependnecies", () => {
});

describe("files", () => {
test("CHANGELOG is not included by default", async () => {
await Promise.all([
write(
join(packageDir, "package.json"),
JSON.stringify({
name: "pack-files-changelog",
version: "1.1.1",
files: ["lib"],
}),
),
write(join(packageDir, "CHANGELOG.md"), "hello"),
write(join(packageDir, "lib", "index.js"), "console.log('hello ./lib/index.js')"),
]);

await pack(packageDir, bunEnv);
const tarball = readTarball(join(packageDir, "pack-files-changelog-1.1.1.tgz"));
expect(tarball.entries).toMatchObject([
{ "pathname": "package/package.json" },
{ "pathname": "package/lib/index.js" },
]);
});
test("cannot exclude LICENSE", async () => {
await Promise.all([
write(
join(packageDir, "package.json"),
JSON.stringify({
name: "pack-files-license",
version: "1.1.1",
files: ["lib", "!LICENSE"],
}),
),
write(join(packageDir, "LICENSE"), "hello"),
write(join(packageDir, "lib", "index.js"), "console.log('hello ./lib/index.js')"),
]);

await pack(packageDir, bunEnv);
const tarball = readTarball(join(packageDir, "pack-files-license-1.1.1.tgz"));
expect(tarball.entries).toMatchObject([
{ "pathname": "package/package.json" },
{ "pathname": "package/LICENSE" },
{ "pathname": "package/lib/index.js" },
]);
});
test("can include files and directories", async () => {
await Promise.all([
write(
Expand Down

0 comments on commit 50d2f76

Please sign in to comment.