-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
24 lines (22 loc) · 792 Bytes
/
index.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
import expose from '~/utils/expose';
import trunk from './mkdir';
import { TSource, IFsCreateDeleteOptions } from '../types';
export default expose(mkdir);
/**
* Deep creates a directory or an array of them.
* It is an *exposed* function: call `mkdir.fn()`, which takes the same arguments, in order to execute on call.
* @param paths a path for a directory, or an array of them.
* @param options an `IFsCreateDeleteOptions` object.
* @returns An asynchronous function -hence, calling `mkdir` won't have any effect until the returned function is called.
*/
function mkdir(
paths: TSource,
options?: IFsCreateDeleteOptions
): () => Promise<void> {
return async () => {
return trunk(
typeof paths === 'function' ? await paths() : await paths,
options
);
};
}