-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresolve.task.ts
43 lines (34 loc) · 1.43 KB
/
resolve.task.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 {z} from 'zod';
import {styleText as st} from 'node:util';
import {TASK_FILE_SUFFIXES, type Task} from './task.js';
import {resolve_input_paths, to_input_paths} from './input_path.js';
export const Args = z
.object({
_: z.array(z.string(), {description: 'the input paths to resolve'}).default(['']),
verbose: z.boolean({description: 'log diagnostics'}).default(false),
})
.strict();
export type Args = z.infer<typeof Args>;
export const task: Task<Args> = {
summary: 'diagnostic that logs resolved filesystem info for the given input paths',
Args,
run: ({args, config, log}): void => {
const {_, verbose} = args;
if (verbose) log.info('raw input paths:', _);
const input_paths = to_input_paths(_);
if (verbose) log.info('input paths:', input_paths);
const {task_root_dirs} = config;
if (verbose) log.info('task root paths:', task_root_dirs);
const {resolved_input_paths, possible_paths_by_input_path, unmapped_input_paths} =
resolve_input_paths(input_paths, task_root_dirs, TASK_FILE_SUFFIXES);
if (verbose) log.info('resolved_input_paths:', resolved_input_paths);
if (verbose) log.info('possible_paths_by_input_path:', possible_paths_by_input_path);
if (verbose) log.info('unmapped_input_paths:', unmapped_input_paths);
for (const p of resolved_input_paths) {
log.info('resolved:', st('green', p.id));
}
if (!resolved_input_paths.length) {
log.warn(st('yellow', 'no input paths were resolved'));
}
},
};