1 |
|
2 |
|
3 | type AppendNullIfNothrow<TOptions, TRet> = TOptions extends { nothrow: infer TVal }
|
4 |
|
5 | ? TVal extends false
|
6 |
|
7 | ? TRet
|
8 |
|
9 | : TRet | null
|
10 |
|
11 | : TRet;
|
12 |
|
13 | type TransformToArrayIfAll<TOptions, TRet> = TOptions extends { all: infer TVal }
|
14 |
|
15 | ? TVal extends true
|
16 |
|
17 | ? readonly TRet[]
|
18 | : TVal extends false
|
19 |
|
20 | ? TRet
|
21 |
|
22 | : readonly TRet[] | TRet
|
23 |
|
24 | : TRet;
|
25 |
|
26 | type ReturnType<TOptions> = AppendNullIfNothrow<TOptions, TransformToArrayIfAll<TOptions, string>>;
|
27 |
|
28 | type Exact<T, U extends T> = {
|
29 | [Key in keyof U]: Key extends keyof T ? U[Key]
|
30 | : never;
|
31 | };
|
32 |
|
33 | declare function which<TOptions extends which.Options>(
|
34 | cmd: string,
|
35 | options?: Exact<which.Options, TOptions>,
|
36 | ): Promise<ReturnType<Exact<which.Options, TOptions>>>;
|
37 |
|
38 | declare namespace which {
|
39 |
|
40 | function sync<TOptions extends Options>(
|
41 | cmd: string,
|
42 | options?: Exact<Options, TOptions>,
|
43 | ): ReturnType<Exact<Options, TOptions>>;
|
44 |
|
45 |
|
46 | interface Options {
|
47 |
|
48 | all?: boolean | undefined;
|
49 |
|
50 | path?: string | undefined;
|
51 |
|
52 | pathExt?: string | undefined;
|
53 |
|
54 | delimiter?: string | undefined;
|
55 |
|
56 | nothrow?: boolean | undefined;
|
57 | }
|
58 | }
|
59 |
|
60 | export = which;
|