-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathrunCleanup.ts
43 lines (36 loc) · 1016 Bytes
/
runCleanup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import chalk from "chalk";
import { execaCommand } from "execa";
import { rimraf } from "rimraf";
import { logLine } from "../shared/cli/lines.js";
import { withSpinner } from "../shared/cli/spinners.js";
import { Mode } from "../shared/types.js";
export async function runCleanup(commands: string[], mode: Mode) {
const failed: string[] = [];
await withSpinner("Cleaning up files", async () => {
if (mode === "migrate") {
// Coverage folders can slow down format and lint times something awful.
// https://github.com/JoshuaKGoldberg/create-typescript-app/issues/1221
await rimraf("coverage*");
}
for (const command of commands) {
try {
await execaCommand(command);
} catch {
failed.push(command);
}
}
});
if (!failed.length) {
return;
}
logLine();
for (const command of failed) {
logLine(
[
chalk.yellow(`🟡 Running \``),
chalk.yellowBright(command),
chalk.yellow(`\` failed. You should run it and fix its complaints.`),
].join(""),
);
}
}