@cowave-cli/utils 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+ import { PathOrFileDescriptor, PathLike } from 'fs';
2
+ /**
3
+ * 创建文件夹
4
+ *
5
+ * @param path 文件夹路径
6
+ */
7
+ export declare const createDir: (path: PathLike) => Promise<void>;
8
+ /**
9
+ * 读取文件夹
10
+ *
11
+ * @param path 文件夹路径
12
+ * @returns {{dirs,files}}
13
+ */
14
+ export declare const readDir: (path: PathLike) => Promise<{
15
+ dirs: any[];
16
+ files: any[];
17
+ }>;
18
+ /** 读取文件
19
+ *
20
+ * @param pathName 文件名
21
+ * @returns
22
+ */
23
+ export declare const readFile: (pathName: PathOrFileDescriptor, encoding?: BufferEncoding) => Promise<string>;
24
+ /** 写入内容
25
+ *
26
+ * @param pathName 文件路径
27
+ * @param content 内容
28
+ */
29
+ export declare const writeFile: (pathName: PathOrFileDescriptor, content: string | NodeJS.ArrayBufferView) => Promise<void>;
30
+ /** 复制文件夹或者文件
31
+ *
32
+ * @param src 文件夹或者文件
33
+ * @param dest 目标文件夹
34
+ */
35
+ export declare const copyFileOrDir: (src: PathLike, dest: PathLike) => Promise<void>;
36
+ /** 删除文件夹或者文件
37
+ *
38
+ * @param path 路径
39
+ */
40
+ export declare const removeFileOrDir: (path: PathLike) => Promise<void>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 判断从toPath引入fromPath的路径相对关系
3
+ *
4
+ * @param fromPath 源路径
5
+ * @param toPath 目标路径
6
+ * @example
7
+ * relation('src/components', 'src/views/home.vue') // '../components/'
8
+ * @returns
9
+ */
10
+ export declare const relation: (fromPath: string, toPath: string) => string;
11
+ /**
12
+ * 过滤文件(仅过滤文件路径,不过滤文件夹路径)
13
+ *
14
+ * @param {string[]} files 文件名列表
15
+ * @returns {} { includeFiles, excludeFiles }
16
+ */
17
+ export declare const filter: (files: string[], basePath?: string | null, includePath?: (string | RegExp)[], excludePath?: (string | RegExp)[]) => Promise<{
18
+ include: string[];
19
+ exclude: string[];
20
+ }>;
21
+ /**
22
+ * 遍历寻找src目录下的所有文件
23
+ * @param dirs
24
+ * @returns
25
+ */
26
+ export declare const findFiles: (srcs: any, includePath?: (string | RegExp)[], excludePath?: (string | RegExp)[]) => Promise<string[]>;