fix(pack): don't automatically include CHANGELOG when files is populated (#13789)

This commit is contained in:
Dylan Conway
2024-09-08 00:56:21 -07:00
committed by GitHub
parent 09fb2d1db0
commit 50d2f76075
2 changed files with 44 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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(