-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat.task.ts
More file actions
35 lines (31 loc) 路 876 Bytes
/
Copy pathformat.task.ts
File metadata and controls
35 lines (31 loc) 路 876 Bytes
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
import { z } from 'zod';
import { format_directory } from './format_directory.ts';
import { paths } from './paths.ts';
import { TaskError, type Task } from './task.ts';
/** @nodocs */
export const Args = z.strictObject({
_: z.array(z.string()).meta({ description: 'files or globs to format' }).optional(),
check: z
.boolean()
.meta({ description: 'exit with a nonzero code if any files are unformatted' })
.default(false)
});
export type Args = z.infer<typeof Args>;
/** @nodocs */
export const task: Task<Args> = {
summary: 'format source files',
Args,
run: async ({ args, log, config }) => {
const { _: patterns, check } = args;
const result = await format_directory(
log,
paths.source,
check,
config.search_filters,
patterns
);
if (!result.ok) {
throw new TaskError(`Failed ${check ? 'formatting check' : 'to format'}.`);
}
}
};