Skip to content

Commit 206c835

Browse files
fix: include bin entry in package.json files (#1149)
## PR Checklist - [x] Addresses an existing open issue: fixes #1147 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Includes a `files` entry if `bin` exists. Also strips a preceding `./` from it if it's there.
1 parent b4e3569 commit 206c835

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"main": "./lib/index.js",
1616
"bin": "./bin/index.js",
1717
"files": [
18-
"bin/",
18+
"bin/index.js",
1919
"lib/",
2020
"package.json",
2121
"LICENSE.md",

script/__snapshots__/migrate-test-e2e.js.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,6 @@ exports[`expected file changes > knip.jsonc 1`] = `
273273
exports[`expected file changes > package.json 1`] = `
274274
"--- a/package.json
275275
+++ b/package.json
276-
@@ ... @@
277-
"main": "./lib/index.js",
278-
"bin": "./bin/index.js",
279-
"files": [
280-
- "bin/",
281-
"lib/",
282-
"package.json",
283-
"LICENSE.md",
284276
@@ ... @@
285277
"scripts": {
286278
"build": "tsup",

src/steps/writing/creation/writePackageJson.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ describe("writePackageJson", () => {
124124

125125
const packageJson = await writePackageJson({
126126
...options,
127+
bin: "./bin/index.js",
127128
excludeAllContributors: true,
128129
excludeCompliance: true,
129130
excludeLintJson: true,
@@ -144,12 +145,14 @@ describe("writePackageJson", () => {
144145
"email": "[email protected]",
145146
"name": "test-author",
146147
},
148+
"bin": "./bin/index.js",
147149
"description": "Test description.",
148150
"devDependencies": {},
149151
"engines": {
150152
"node": ">=18",
151153
},
152154
"files": [
155+
"bin/index.js",
153156
"lib/",
154157
"package.json",
155158
"LICENSE.md",

src/steps/writing/creation/writePackageJson.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ export async function writePackageJson(options: Options) {
6060
engines: {
6161
node: ">=18",
6262
},
63-
files: ["lib/", "package.json", "LICENSE.md", "README.md"],
63+
files: [
64+
options.bin?.replace(/^\.\//, ""),
65+
"lib/",
66+
"package.json",
67+
"LICENSE.md",
68+
"README.md",
69+
].filter(Boolean),
6470
license: "MIT",
6571
"lint-staged": {
6672
"*": "prettier --ignore-unknown --write",

0 commit comments

Comments
 (0)