Skip to content

Commit 48e05e6

Browse files
feat: remove more common unnecessary files (#513)
## PR Checklist - [x] Addresses an existing open issue: fixes #452; fixes #512 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/template-typescript-node-package/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Adds some more globs to the list of those to remove.
1 parent 7ea76a0 commit 48e05e6

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

cspell.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
"knip",
2020
"lcov",
2121
"markdownlintignore",
22+
"npmignore",
2223
"npmpackagejsonlintrc",
2324
"outro",
2425
"packagejson",
25-
"Unstaged",
2626
"quickstart",
27+
"Unstaged",
2728
"wontfix"
2829
]
2930
}

src/hydrate/steps/clearUnnecessaryFiles.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ vi.mock("execa", () => ({
1111
}));
1212

1313
describe("clearUnnecessaryFiles", () => {
14-
it("runs all commands even when they fail", async () => {
14+
it("removes all globs, quoted", async () => {
1515
await clearUnnecessaryFiles();
1616

17-
expect(mockExecaCommand).toHaveBeenCalledWith(`rm -rf ./src/**/*.js`);
17+
expect(mockExecaCommand).toHaveBeenCalledWith(
18+
`rm -rf "./src/**/*.js" ".eslintrc.j*" ".npmignore" ".prettierrc.*" "babel.*" "CODE_OF_CONDUCT.md" "CONTRIBUTING.md" "DEVELOPMENT.md" "dist" "jest.*" "lib" "package-lock.json" "yarn.lock"`
19+
);
1820
});
1921
});
+22-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
import { execaCommand } from "execa";
22

3+
const ignoreGlobs = [
4+
"./src/**/*.js",
5+
".eslintrc.j*",
6+
".npmignore",
7+
".prettierrc.*",
8+
"babel.*",
9+
"CODE_OF_CONDUCT.md",
10+
"CONTRIBUTING.md",
11+
"DEVELOPMENT.md",
12+
"dist",
13+
"jest.*",
14+
"lib",
15+
"package-lock.json",
16+
"yarn.lock",
17+
];
18+
319
export async function clearUnnecessaryFiles() {
4-
for (const glob of [
5-
"dist lib package-lock.json yarn.lock",
6-
".eslintrc*",
7-
"./src/**/*.js",
8-
]) {
9-
try {
10-
await execaCommand(`rm -rf ${glob}`);
11-
} catch {
12-
// (we ignore failures if nothing matched)
13-
}
20+
try {
21+
await execaCommand(
22+
`rm -rf ${ignoreGlobs.map((glob) => `"${glob}"`).join(" ")}`
23+
);
24+
} catch {
25+
// (we ignore failures if nothing matched)
1426
}
1527
}

0 commit comments

Comments
 (0)