@ainc/fs 0.1.22 → 0.1.24

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.
Files changed (64) hide show
  1. package/dist/cache.d.ts +16 -0
  2. package/dist/cache.js +24 -0
  3. package/dist/dict.d.ts +21 -0
  4. package/dist/dict.js +66 -0
  5. package/dist/download.js +4 -16
  6. package/dist/downloadFile.js +19 -13
  7. package/dist/gzip.d.ts +13 -0
  8. package/dist/gzip.js +50 -0
  9. package/dist/index.d.ts +37 -1
  10. package/dist/index.exports.json +34 -0
  11. package/dist/index.js +60 -3
  12. package/dist/isEsmModule.d.ts +18 -0
  13. package/dist/isEsmModule.js +63 -0
  14. package/dist/loadPackageDescription.d.ts +61 -0
  15. package/dist/loadPackageDescription.js +71 -0
  16. package/dist/loadTsConfig.d.ts +87 -0
  17. package/dist/loadTsConfig.js +219 -0
  18. package/dist/match.d.ts +30 -0
  19. package/dist/match.js +59 -0
  20. package/dist/promises.d.ts +69 -0
  21. package/dist/promises.js +103 -0
  22. package/dist/resolveAlias.d.ts +25 -0
  23. package/dist/resolveAlias.js +82 -0
  24. package/dist/resolveDirect.d.ts +15 -0
  25. package/dist/resolveDirect.js +144 -0
  26. package/dist/resolveExports.d.ts +19 -0
  27. package/dist/resolveExports.js +54 -0
  28. package/dist/resolveImports.d.ts +21 -0
  29. package/dist/resolveImports.js +114 -0
  30. package/dist/resolveModuleDir.d.ts +12 -0
  31. package/dist/resolveModuleDir.js +67 -0
  32. package/dist/resolveModuleId.d.ts +6 -0
  33. package/dist/resolveModuleId.js +32 -0
  34. package/dist/resolvePath.d.ts +23 -0
  35. package/dist/resolvePath.js +86 -0
  36. package/dist/resolvePaths.d.ts +13 -0
  37. package/dist/resolvePaths.js +42 -0
  38. package/dist/split.d.ts +6 -0
  39. package/dist/split.js +24 -0
  40. package/dist/sys.d.ts +60 -0
  41. package/dist/sys.js +260 -0
  42. package/esm/cache.mjs +22 -0
  43. package/esm/dict.mjs +63 -0
  44. package/esm/download.mjs +4 -16
  45. package/esm/downloadFile.mjs +19 -13
  46. package/esm/gzip.mjs +47 -0
  47. package/esm/index.exports.json +34 -0
  48. package/esm/index.mjs +29 -1
  49. package/esm/isEsmModule.mjs +59 -0
  50. package/esm/loadPackageDescription.mjs +67 -0
  51. package/esm/loadTsConfig.mjs +215 -0
  52. package/esm/match.mjs +53 -0
  53. package/esm/promises.mjs +96 -0
  54. package/esm/resolveAlias.mjs +79 -0
  55. package/esm/resolveDirect.mjs +142 -0
  56. package/esm/resolveExports.mjs +51 -0
  57. package/esm/resolveImports.mjs +112 -0
  58. package/esm/resolveModuleDir.mjs +64 -0
  59. package/esm/resolveModuleId.mjs +30 -0
  60. package/esm/resolvePath.mjs +84 -0
  61. package/esm/resolvePaths.mjs +40 -0
  62. package/esm/split.mjs +22 -0
  63. package/esm/sys.mjs +258 -0
  64. package/package.json +5 -6
@@ -0,0 +1,71 @@
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2023-12-02 11:43:57
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.loadPackageDescription = loadPackageDescription;
10
+ exports.readPackageDescription = readPackageDescription;
11
+ exports.resolvePackageDescription = resolvePackageDescription;
12
+ /**
13
+ *****************************************
14
+ * 加载依赖
15
+ *****************************************
16
+ */
17
+ const node_path_1 = require("node:path");
18
+ const stat_1 = require("./stat");
19
+ const lookup_1 = require("./lookup");
20
+ const jsonc_1 = require("./jsonc");
21
+ const readFile_1 = require("./readFile");
22
+ /**
23
+ *****************************************
24
+ * 加载包描述
25
+ *****************************************
26
+ */
27
+ function loadPackageDescription(from) {
28
+ const data = resolvePackageDescription(from);
29
+ // 返回配置
30
+ if (data) {
31
+ return data.config;
32
+ }
33
+ }
34
+ /**
35
+ *****************************************
36
+ * 读取包描述
37
+ *****************************************
38
+ */
39
+ function readPackageDescription(dir) {
40
+ const data = resolvePackageDescription(dir);
41
+ // 返回配置
42
+ if (data && data.path.startsWith(dir)) {
43
+ return data.config;
44
+ }
45
+ }
46
+ /**
47
+ *****************************************
48
+ * 缓存
49
+ *****************************************
50
+ */
51
+ const cache = new Map();
52
+ const moduleDir = node_path_1.sep + 'node_modules';
53
+ /**
54
+ *****************************************
55
+ * 解析包配置
56
+ *****************************************
57
+ */
58
+ function resolvePackageDescription(from) {
59
+ return (0, lookup_1.lookup)('package.json', {
60
+ from,
61
+ cache,
62
+ resolve(path, dir) {
63
+ if ((0, stat_1.isFile)(path)) {
64
+ return { dir, path, config: (0, jsonc_1.json)((0, readFile_1.readFile)(path)) };
65
+ }
66
+ if (dir.endsWith(moduleDir)) {
67
+ return { dir, path };
68
+ }
69
+ },
70
+ });
71
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ *****************************************
3
+ * 编译配置
4
+ *****************************************
5
+ */
6
+ export interface CompilerOptions {
7
+ target?: string;
8
+ lib?: string[];
9
+ module?: string;
10
+ moduleResolution?: string;
11
+ declaration?: boolean;
12
+ declarationMap?: boolean;
13
+ strict?: boolean;
14
+ sourceMap?: boolean;
15
+ esModuleInterop?: boolean;
16
+ experimentalDecorators?: boolean;
17
+ noImplicitAny?: boolean;
18
+ allowJs?: boolean;
19
+ noEmit?: boolean;
20
+ jsx?: string;
21
+ isolatedModules?: boolean;
22
+ resolveJsonModule?: boolean;
23
+ forceConsistentCasingInFileNames?: boolean;
24
+ skipLibCheck?: boolean;
25
+ skipDefaultLibCheck?: boolean;
26
+ rootDirs?: string[];
27
+ rootDir?: string;
28
+ outDir?: string;
29
+ baseUrl?: string;
30
+ paths?: Record<string, string[]>;
31
+ [key: string]: unknown;
32
+ }
33
+ /**
34
+ *****************************************
35
+ * 监听配置
36
+ *****************************************
37
+ */
38
+ export interface WatchOptions {
39
+ watchFile?: string;
40
+ watchDirectory?: string;
41
+ excludeDirectories?: string[];
42
+ excludeFiles?: string[];
43
+ fallbackPolling?: string;
44
+ synchronousWatchDirectory?: boolean;
45
+ [key: string]: unknown;
46
+ }
47
+ /**
48
+ *****************************************
49
+ * TsConfig
50
+ *****************************************
51
+ */
52
+ export interface TsConfig {
53
+ extends?: string | string[];
54
+ include?: string[];
55
+ exclude?: string[];
56
+ files?: string[];
57
+ compileOnSave?: boolean;
58
+ compilerOptions?: CompilerOptions;
59
+ watchOptions?: WatchOptions;
60
+ }
61
+ /**
62
+ *****************************************
63
+ * TsConfig
64
+ *****************************************
65
+ */
66
+ export interface TsConfigDescription {
67
+ path: string;
68
+ config: TsConfig;
69
+ }
70
+ /**
71
+ *****************************************
72
+ * 加载 TS 配置
73
+ *****************************************
74
+ */
75
+ export declare function loadTsConfig(from?: string): TsConfig | undefined;
76
+ /**
77
+ *****************************************
78
+ * 加载编译配置
79
+ *****************************************
80
+ */
81
+ export declare function loadCompilerOptions(from?: string): CompilerOptions | undefined;
82
+ /**
83
+ *****************************************
84
+ * 解析 TS 配置
85
+ *****************************************
86
+ */
87
+ export declare function resolveTsConfig(from?: string): TsConfigDescription | undefined;
@@ -0,0 +1,219 @@
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2023-12-30 13:48:09
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.loadTsConfig = loadTsConfig;
10
+ exports.loadCompilerOptions = loadCompilerOptions;
11
+ exports.resolveTsConfig = resolveTsConfig;
12
+ /**
13
+ *****************************************
14
+ * 加载依赖
15
+ *****************************************
16
+ */
17
+ const node_fs_1 = require("node:fs");
18
+ const node_path_1 = require("node:path");
19
+ const relative_1 = require("./relative");
20
+ const resolveFile_1 = require("./resolveFile");
21
+ const stat_1 = require("./stat");
22
+ const lookup_1 = require("./lookup");
23
+ const jsonc_1 = require("./jsonc");
24
+ const match_1 = require("./match");
25
+ const resolveModuleDir_1 = require("./resolveModuleDir");
26
+ /**
27
+ *****************************************
28
+ * 加载 TS 配置
29
+ *****************************************
30
+ */
31
+ function loadTsConfig(from) {
32
+ const data = resolveTsConfig(from);
33
+ // 返回配置
34
+ if (data) {
35
+ return data.config;
36
+ }
37
+ }
38
+ /**
39
+ *****************************************
40
+ * 加载编译配置
41
+ *****************************************
42
+ */
43
+ function loadCompilerOptions(from) {
44
+ const data = resolveTsConfig(from);
45
+ // 返回配置
46
+ if (data && data.config) {
47
+ return data.config.compilerOptions;
48
+ }
49
+ }
50
+ /**
51
+ *****************************************
52
+ * 缓存内容
53
+ *****************************************
54
+ */
55
+ const cache = new Map();
56
+ /**
57
+ *****************************************
58
+ * 解析 TS 配置
59
+ *****************************************
60
+ */
61
+ function resolveTsConfig(from) {
62
+ return (0, lookup_1.lookup)('tsconfig.json', {
63
+ from,
64
+ cache,
65
+ resolve(path) {
66
+ return (0, stat_1.isFile)(path) ? loadTsConfigFile(path) : undefined;
67
+ },
68
+ });
69
+ }
70
+ /**
71
+ *****************************************
72
+ * 解析 TS 配置文件
73
+ *****************************************
74
+ */
75
+ function loadTsConfigFile(path) {
76
+ const config = parseTsConfig(path, new Set([path]), ['.json', node_path_1.sep + 'tsconfig.json']);
77
+ const dir = (0, node_path_1.dirname)(path);
78
+ // 移除继承属性
79
+ config.extends = undefined;
80
+ // 格式化 include 配置
81
+ if (config.include) {
82
+ config.include = config.include.map(path => (0, relative_1.relative)(dir, path));
83
+ }
84
+ // 格式化 exclude 配置
85
+ if (config.exclude) {
86
+ config.exclude = config.exclude.map(path => (0, relative_1.relative)(dir, path));
87
+ }
88
+ // 格式化 files 配置
89
+ if (config.files) {
90
+ config.files = config.files.map(path => (0, relative_1.relative)(dir, path));
91
+ }
92
+ // 返回结果
93
+ return { path, config };
94
+ }
95
+ /**
96
+ *****************************************
97
+ * 解析配置
98
+ *****************************************
99
+ */
100
+ function parseTsConfig(path, tracker, extensions) {
101
+ const data = (0, jsonc_1.jsonc)((0, node_fs_1.readFileSync)(path, 'utf8'));
102
+ const dir = (0, node_path_1.dirname)(path);
103
+ const config = normalizeTsConfig(data, dir);
104
+ // 不存在继承,直接返回
105
+ if (!config.extends) {
106
+ return config;
107
+ }
108
+ // 获取继承列表
109
+ const extendsList = Array.isArray(config.extends) ? config.extends : [config.extends];
110
+ const configs = extendsList.map(path => parseExtendsTsConfig(path, dir, tracker, extensions));
111
+ // 追加当前配置
112
+ configs.push(config);
113
+ // 合并配置
114
+ return configs.reduce(mergeTsConfig);
115
+ }
116
+ /**
117
+ *****************************************
118
+ * 合并配置
119
+ *****************************************
120
+ */
121
+ function mergeTsConfig(target, source) {
122
+ const { baseUrl, paths } = source.compilerOptions || {};
123
+ const config = { ...target, ...source };
124
+ // 合并配置项
125
+ config.compilerOptions = { ...target.compilerOptions, ...source.compilerOptions };
126
+ config.watchOptions = { ...target.watchOptions, ...source.watchOptions };
127
+ // 更新 paths 配置
128
+ if (baseUrl || paths) {
129
+ config.compilerOptions.baseUrl = baseUrl;
130
+ config.compilerOptions.paths = paths;
131
+ }
132
+ // 返回配置
133
+ return config;
134
+ }
135
+ /**
136
+ *****************************************
137
+ * 解析继承配置
138
+ *****************************************
139
+ */
140
+ function parseExtendsTsConfig(path, from, tracker, extensions) {
141
+ const extendsFile = resolveExtendsFile(path, from, extensions);
142
+ // 未找到文件
143
+ if (!extendsFile) {
144
+ throw new Error(`file '${path}' not found.`);
145
+ }
146
+ // 循环引用
147
+ if (tracker.has(extendsFile)) {
148
+ throw new Error(`circularity detected while resolving configuration: ${extendsFile}`);
149
+ }
150
+ // 添加引用文件
151
+ tracker.add(extendsFile);
152
+ // 解析文件
153
+ return parseTsConfig(extendsFile, tracker, extensions);
154
+ }
155
+ /**
156
+ *****************************************
157
+ * 解析继承文件地址
158
+ *****************************************
159
+ */
160
+ function resolveExtendsFile(path, from, extensions) {
161
+ // 解析相对路径
162
+ if ((0, relative_1.isRelative)(path)) {
163
+ return (0, resolveFile_1.resolveFile)((0, node_path_1.resolve)(from, path), extensions);
164
+ }
165
+ // 解析绝对路径
166
+ if ((0, node_path_1.isAbsolute)(path)) {
167
+ return (0, resolveFile_1.resolveFile)(path, extensions);
168
+ }
169
+ // 解析模块目录
170
+ const moduleDirs = (0, resolveModuleDir_1.resolveModuleDirs)(from);
171
+ // 模块目录
172
+ return (0, match_1.match)(moduleDirs, dir => (0, resolveFile_1.resolveFile)((0, node_path_1.resolve)(dir, path), extensions));
173
+ }
174
+ /**
175
+ *****************************************
176
+ * 格式化配置
177
+ *****************************************
178
+ */
179
+ function normalizeTsConfig(config, dir) {
180
+ const compilerOptions = config.compilerOptions;
181
+ const watchOptions = config.watchOptions;
182
+ // 格式化 include 配置
183
+ if (config.include) {
184
+ config.include = config.include.map(path => (0, node_path_1.resolve)(dir, path));
185
+ }
186
+ // 格式化 exclude 配置
187
+ if (config.exclude) {
188
+ config.exclude = config.exclude.map(path => (0, node_path_1.resolve)(dir, path));
189
+ }
190
+ // 格式化 files 配置
191
+ if (config.files) {
192
+ config.files = config.files.map(path => (0, node_path_1.resolve)(dir, path));
193
+ }
194
+ // 格式化 compilerOptions 配置
195
+ if (compilerOptions) {
196
+ // 格式化 baseUrl 配置
197
+ if (compilerOptions.baseUrl) {
198
+ compilerOptions.baseUrl = (0, node_path_1.resolve)(dir, compilerOptions.baseUrl);
199
+ }
200
+ // 格式化 outDir 配置
201
+ if (compilerOptions.outDir) {
202
+ compilerOptions.outDir = (0, node_path_1.resolve)(dir, compilerOptions.outDir);
203
+ }
204
+ // 格式化 rootDir 配置
205
+ if (compilerOptions.rootDir) {
206
+ compilerOptions.rootDir = (0, node_path_1.resolve)(dir, compilerOptions.rootDir);
207
+ }
208
+ // 格式化 rootDirs 配置
209
+ if (compilerOptions.rootDirs) {
210
+ compilerOptions.rootDirs = compilerOptions.rootDirs.map(path => (0, node_path_1.resolve)(dir, path));
211
+ }
212
+ }
213
+ // 格式化监听路径
214
+ if (watchOptions && watchOptions.excludeDirectories) {
215
+ watchOptions.excludeDirectories = watchOptions.excludeDirectories.map(path => (0, node_path_1.resolve)(dir, path));
216
+ }
217
+ // 返回配置
218
+ return config;
219
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ *****************************************
3
+ * 空函数
4
+ *****************************************
5
+ */
6
+ export declare function noop(): void;
7
+ /**
8
+ *****************************************
9
+ * nil 函数
10
+ *****************************************
11
+ */
12
+ export declare function nil(): null;
13
+ /**
14
+ *****************************************
15
+ * false
16
+ *****************************************
17
+ */
18
+ export declare function falsy(): boolean;
19
+ /**
20
+ *****************************************
21
+ * 一元函数
22
+ *****************************************
23
+ */
24
+ export declare function unary<T>(value: T): T;
25
+ /**
26
+ *****************************************
27
+ * 执行匹配
28
+ *****************************************
29
+ */
30
+ export declare function match<T, P>(list: T[], handler: (value: T) => P): P | undefined;
package/dist/match.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2026-03-18 15:12:42
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.noop = noop;
10
+ exports.nil = nil;
11
+ exports.falsy = falsy;
12
+ exports.unary = unary;
13
+ exports.match = match;
14
+ /**
15
+ *****************************************
16
+ * 空函数
17
+ *****************************************
18
+ */
19
+ function noop() {
20
+ // do nothing
21
+ }
22
+ /**
23
+ *****************************************
24
+ * nil 函数
25
+ *****************************************
26
+ */
27
+ function nil() {
28
+ return null;
29
+ }
30
+ /**
31
+ *****************************************
32
+ * false
33
+ *****************************************
34
+ */
35
+ function falsy() {
36
+ return false;
37
+ }
38
+ /**
39
+ *****************************************
40
+ * 一元函数
41
+ *****************************************
42
+ */
43
+ function unary(value) {
44
+ return value;
45
+ }
46
+ /**
47
+ *****************************************
48
+ * 执行匹配
49
+ *****************************************
50
+ */
51
+ function match(list, handler) {
52
+ for (let i = 0; i < list.length; i++) {
53
+ const result = handler(list[i]);
54
+ // 查找到结果
55
+ if (result !== undefined) {
56
+ return result;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ *****************************************
3
+ * 加载依赖
4
+ *****************************************
5
+ */
6
+ import { Readable, Writable, PipeOptions } from 'node:stream';
7
+ import { Mode, RmOptions, StatOptions as IStatOptions } from 'node:fs';
8
+ /**
9
+ *****************************************
10
+ * 状态选项
11
+ *****************************************
12
+ */
13
+ export interface StatOptions extends IStatOptions {
14
+ bigint?: false | undefined;
15
+ }
16
+ /**
17
+ *****************************************
18
+ * 获取文件状态
19
+ *****************************************
20
+ */
21
+ export declare function stat(path: string, options?: StatOptions): Promise<import("node:fs").Stats | null>;
22
+ /**
23
+ *****************************************
24
+ * 删除文件
25
+ *****************************************
26
+ */
27
+ export declare function rm(path: string, options?: RmOptions): Promise<void>;
28
+ /**
29
+ *****************************************
30
+ * 选项
31
+ *****************************************
32
+ */
33
+ export interface MkdirOptions {
34
+ force?: boolean;
35
+ mode?: Mode | undefined;
36
+ recursive?: boolean;
37
+ }
38
+ /**
39
+ *****************************************
40
+ * 创建文件目录
41
+ *****************************************
42
+ */
43
+ export declare function mkdir(path: string, options?: MkdirOptions): Promise<boolean>;
44
+ /**
45
+ *****************************************
46
+ * pipe
47
+ *****************************************
48
+ */
49
+ export declare function pipe(src: Readable, dest: Writable, options?: PipeOptions): Promise<unknown>;
50
+ /**
51
+ *****************************************
52
+ * 读取文件
53
+ *****************************************
54
+ */
55
+ export declare function readFile(path: string): Promise<string | undefined>;
56
+ /**
57
+ *****************************************
58
+ * 选项
59
+ *****************************************
60
+ */
61
+ export interface WriteFileOptions {
62
+ force?: boolean;
63
+ }
64
+ /**
65
+ *****************************************
66
+ * 写入文件
67
+ *****************************************
68
+ */
69
+ export declare function writeFile(path: string, content: string, options?: WriteFileOptions): Promise<boolean>;
@@ -0,0 +1,103 @@
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2026-03-21 12:37:59
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.stat = stat;
10
+ exports.rm = rm;
11
+ exports.mkdir = mkdir;
12
+ exports.pipe = pipe;
13
+ exports.readFile = readFile;
14
+ exports.writeFile = writeFile;
15
+ const node_path_1 = require("node:path");
16
+ const fs = require("node:fs/promises");
17
+ /**
18
+ *****************************************
19
+ * 获取文件状态
20
+ *****************************************
21
+ */
22
+ async function stat(path, options) {
23
+ return fs.stat(path, options).catch(err => err.code === 'ENOENT' ? null : Promise.reject(err));
24
+ }
25
+ /**
26
+ *****************************************
27
+ * 删除文件
28
+ *****************************************
29
+ */
30
+ async function rm(path, options) {
31
+ if (await stat(path)) {
32
+ await fs.rm(path, { force: true, recursive: true, ...options });
33
+ }
34
+ }
35
+ /**
36
+ *****************************************
37
+ * 创建文件目录
38
+ *****************************************
39
+ */
40
+ async function mkdir(path, options) {
41
+ const stats = await stat(path);
42
+ const opts = { recursive: true, ...options };
43
+ // 创建目录
44
+ if (!stats) {
45
+ await fs.mkdir(path, opts);
46
+ return true;
47
+ }
48
+ else if (stats.isDirectory()) {
49
+ return true;
50
+ }
51
+ else if (!opts.force) {
52
+ return false;
53
+ }
54
+ else {
55
+ await fs.unlink(path);
56
+ await fs.mkdir(path, opts);
57
+ return true;
58
+ }
59
+ }
60
+ /**
61
+ *****************************************
62
+ * pipe
63
+ *****************************************
64
+ */
65
+ async function pipe(src, dest, options) {
66
+ return new Promise((resolve, reject) => {
67
+ src.once('close', resolve);
68
+ src.once('error', reject);
69
+ src.pipe(dest, options);
70
+ });
71
+ }
72
+ /**
73
+ *****************************************
74
+ * 读取文件
75
+ *****************************************
76
+ */
77
+ async function readFile(path) {
78
+ const stats = await stat(path);
79
+ if (stats && !stats.isDirectory()) {
80
+ return fs.readFile(path, 'utf8');
81
+ }
82
+ }
83
+ /**
84
+ *****************************************
85
+ * 写入文件
86
+ *****************************************
87
+ */
88
+ async function writeFile(path, content, options) {
89
+ const stats = await stat(path);
90
+ if (stats) {
91
+ if (!options || !options.force) {
92
+ return false;
93
+ }
94
+ else {
95
+ await rm(path);
96
+ }
97
+ }
98
+ // 写入文件内容
99
+ await fs.mkdir((0, node_path_1.dirname)(path), { recursive: true });
100
+ await fs.writeFile(path, content);
101
+ // 返回结果
102
+ return true;
103
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ *****************************************
3
+ * 加载依赖
4
+ *****************************************
5
+ */
6
+ import { Dict } from './dict';
7
+ /**
8
+ *****************************************
9
+ * 处理函数
10
+ *****************************************
11
+ */
12
+ export type Handler = (path: string) => string | null | undefined;
13
+ export type Match = (id: string, handler: Handler) => string | null | undefined;
14
+ /**
15
+ *****************************************
16
+ * 解析别名
17
+ *****************************************
18
+ */
19
+ export declare function resolveAlias(alias: Record<string, string>): Dict<Match>;
20
+ /**
21
+ *****************************************
22
+ * 解析字典
23
+ *****************************************
24
+ */
25
+ export declare function resolveDict<T, P>(data: Record<string, T>, handler: (key: string, value: T) => P): Dict<P>;