-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.task.ts
More file actions
54 lines (49 loc) · 1.48 KB
/
Copy pathclean.task.ts
File metadata and controls
54 lines (49 loc) · 1.48 KB
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
44
45
46
47
48
49
50
51
52
53
54
import { spawn } from '@fuzdev/fuz_util/process.ts';
import { z } from 'zod';
import { GitOrigin } from '@fuzdev/fuz_util/git.ts';
import type { Task } from './task.ts';
import { clean_fs } from './clean_fs.ts';
/** @nodocs */
export const Args = z.strictObject({
build_dev: z.boolean().meta({ description: 'delete the Gro build dev directory' }).default(false),
build_dist: z
.boolean()
.meta({ description: 'delete the Gro build dist directory' })
.default(false),
sveltekit: z
.boolean()
.meta({ description: 'delete the SvelteKit directory and Vite cache' })
.default(false),
nodemodules: z
.boolean()
.meta({ description: 'delete the node_modules directory' })
.default(false),
git: z
.boolean()
.meta({
description:
'run "git remote prune" to delete local branches referencing nonexistent remote branches'
})
.default(false),
git_origin: GitOrigin.meta({ description: 'the origin to "git remote prune"' }).default('origin')
});
export type Args = z.infer<typeof Args>;
/** @nodocs */
export const task: Task<Args> = {
summary: 'remove temporary dev and build files, and optionally prune git branches',
Args,
run: async ({ args }): Promise<void> => {
const { build_dev, build_dist, sveltekit, nodemodules, git, git_origin } = args;
await clean_fs({
build: !build_dev && !build_dist,
build_dev,
build_dist,
sveltekit,
nodemodules
});
// lop off stale git branches
if (git) {
await spawn('git', ['remote', 'prune', git_origin]);
}
}
};