maishu-scripts 1.4.1 → 1.4.5
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.
- package/out/index.d.ts +2 -4
- package/out/index.js +4 -2
- package/out/modules/actions/babel-compile.d.ts +11 -1
- package/out/modules/actions/babel-compile.js +76 -55
- package/out/modules/actions/copy-file.js +12 -4
- package/out/modules/compile.d.ts +1 -0
- package/out/modules/compile.js +9 -5
- package/out/modules/configs.d.ts +3 -3
- package/out/modules/configs.js +7 -4
- package/out/modules/errors.d.ts +1 -0
- package/out/modules/errors.js +8 -0
- package/out/package.json +33 -0
- package/package.json +4 -3
- package/src/index.ts +2 -1
- package/src/modules/actions/babel-compile.test.ts +436 -0
- package/src/modules/actions/babel-compile.ts +80 -64
- package/src/modules/actions/copy-file.ts +12 -4
- package/src/modules/compile.test.ts +236 -189
- package/src/modules/compile.ts +14 -7
- package/src/modules/configs.ts +5 -6
- package/src/modules/errors.ts +8 -0
- package/src/modules/project-compiler.test.ts +245 -40
- package/out/modules/actions/biel-compile.d.ts +0 -7
- package/out/modules/actions/biel-compile.js +0 -153
|
@@ -1,189 +1,236 @@
|
|
|
1
|
-
import { generateCode, isIgnoredFile, watchDirectory } from "./compile";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import * as fs from "fs";
|
|
4
|
-
import { create as createTsCompiler } from "
|
|
5
|
-
import ts from "typescript";
|
|
6
|
-
import
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
generateCode(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
expect(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
1
|
+
import { generateCode, isIgnoredFile, watchDirectory } from "./compile";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import { create as createTsCompiler } from "./actions/ts-compile";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import copyFile from "./actions/copy-file";
|
|
7
|
+
import { errors } from "./errors";
|
|
8
|
+
|
|
9
|
+
// 公共常量
|
|
10
|
+
const SRC_PATH = "test/src";
|
|
11
|
+
const DEST_PATH = "test/out";
|
|
12
|
+
const PROJECT_PATH = path.join(__dirname, "..", "..");
|
|
13
|
+
|
|
14
|
+
// 清理输出目录的工具函数
|
|
15
|
+
function cleanDir(dir: string) {
|
|
16
|
+
if (fs.existsSync(dir)) {
|
|
17
|
+
fs.rmSync(dir, { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe("Compile Test", function () {
|
|
22
|
+
|
|
23
|
+
test("copyFile test", function () {
|
|
24
|
+
let srcExists = fs.existsSync(SRC_PATH);
|
|
25
|
+
expect(srcExists).toBe(true);
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
test("generateCode test", function () {
|
|
29
|
+
cleanDir(DEST_PATH);
|
|
30
|
+
generateCode(SRC_PATH, DEST_PATH, PROJECT_PATH);
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test("generateCode with callback test", function () {
|
|
34
|
+
cleanDir(DEST_PATH);
|
|
35
|
+
const callback = jest.fn();
|
|
36
|
+
generateCode(SRC_PATH, DEST_PATH, PROJECT_PATH, callback);
|
|
37
|
+
expect(callback.mock.calls.length).toBeGreaterThan(0);
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test("generateCode with skipFiles test", function () {
|
|
41
|
+
cleanDir(DEST_PATH);
|
|
42
|
+
|
|
43
|
+
let executedPaths: string[] = [];
|
|
44
|
+
generateCode(SRC_PATH, DEST_PATH, PROJECT_PATH, (filePath: string) => {
|
|
45
|
+
executedPaths.push(filePath);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(executedPaths.some(p => p.includes("controllers"))).toBe(true);
|
|
49
|
+
|
|
50
|
+
// 忽略掉 controllers 目录
|
|
51
|
+
const skipFiles = [new RegExp("controllers")];
|
|
52
|
+
executedPaths = [];
|
|
53
|
+
generateCode({
|
|
54
|
+
sourceDir: SRC_PATH, outDir: DEST_PATH, projectPath: PROJECT_PATH, skipFiles,
|
|
55
|
+
callback(filePath: string) {
|
|
56
|
+
executedPaths.push(filePath);
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
expect(executedPaths.some(p => p.includes("controllers"))).toBe(false);
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
test("generateCode 根据文件夹使用不同的 TS 编译器", async function () {
|
|
63
|
+
cleanDir(DEST_PATH);
|
|
64
|
+
|
|
65
|
+
const srcCompiler = createTsCompiler({
|
|
66
|
+
target: ts.ScriptTarget.ES2015,
|
|
67
|
+
module: ts.ModuleKind.CommonJS,
|
|
68
|
+
declaration: true,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const staticCompiler = createTsCompiler({
|
|
72
|
+
target: ts.ScriptTarget.ES5,
|
|
73
|
+
module: ts.ModuleKind.AMD,
|
|
74
|
+
declaration: false,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const mainFile = "main.ts";
|
|
78
|
+
const staticFile = "static/index.ts";
|
|
79
|
+
const mainFilePath = path.resolve(SRC_PATH, mainFile);
|
|
80
|
+
expect(fs.existsSync(mainFilePath)).toBeTruthy();
|
|
81
|
+
const staticFilePath = path.resolve(SRC_PATH, staticFile);
|
|
82
|
+
expect(fs.existsSync(staticFilePath)).toBeTruthy();
|
|
83
|
+
|
|
84
|
+
generateCode({
|
|
85
|
+
sourceDir: SRC_PATH, outDir: DEST_PATH, projectPath: PROJECT_PATH,
|
|
86
|
+
fileAction(filePath: string) {
|
|
87
|
+
const ext = path.extname(filePath);
|
|
88
|
+
if (ext !== ".ts" && ext !== ".tsx") {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
filePath = filePath.replace(/\\/g, "/");
|
|
92
|
+
if (filePath.startsWith("test/src/static/")) {
|
|
93
|
+
return staticCompiler;
|
|
94
|
+
}
|
|
95
|
+
return srcCompiler;
|
|
96
|
+
},
|
|
97
|
+
callback(_filePath: string) {
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
// 等待异步编译完成
|
|
102
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
103
|
+
|
|
104
|
+
const mainOutFile = "main.js";
|
|
105
|
+
const staticOutFile = "static/index.js";
|
|
106
|
+
const mainOutFilePath = path.resolve(DEST_PATH, mainOutFile);
|
|
107
|
+
const staticOutFilePath = path.resolve(DEST_PATH, staticOutFile);
|
|
108
|
+
expect(fs.existsSync(mainOutFilePath)).toBeTruthy();
|
|
109
|
+
expect(fs.existsSync(staticOutFilePath)).toBeTruthy();
|
|
110
|
+
|
|
111
|
+
const mainFileContent = fs.readFileSync(mainOutFilePath, "utf-8");
|
|
112
|
+
const staticFileContent = fs.readFileSync(staticOutFilePath, "utf-8");
|
|
113
|
+
|
|
114
|
+
expect(mainFileContent.includes("Object.defineProperty(exports, \"__esModule\"")).toBe(true);
|
|
115
|
+
expect(staticFileContent.includes("define([")).toBe(true);
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
test("generateCode 参数校验", function () {
|
|
119
|
+
expect(() => generateCode("", DEST_PATH, PROJECT_PATH)).toThrow();
|
|
120
|
+
expect(() => generateCode(SRC_PATH, "", PROJECT_PATH)).toThrow();
|
|
121
|
+
expect(() => generateCode(SRC_PATH, DEST_PATH, "")).toThrow();
|
|
122
|
+
expect(() => generateCode("/nonexistent/path", DEST_PATH, PROJECT_PATH)).toThrow();
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
test("generateCode with defaultAction", function () {
|
|
126
|
+
cleanDir(DEST_PATH);
|
|
127
|
+
|
|
128
|
+
const customAction = jest.fn();
|
|
129
|
+
generateCode({
|
|
130
|
+
sourceDir: SRC_PATH, outDir: DEST_PATH, projectPath: PROJECT_PATH,
|
|
131
|
+
fileAction() {
|
|
132
|
+
return undefined; // fileAction 始终返回 undefined
|
|
133
|
+
},
|
|
134
|
+
defaultAction: customAction as any,
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
// defaultAction 应该被调用
|
|
138
|
+
expect(customAction.mock.calls.length).toBeGreaterThan(0);
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
test("generateCode defaultAction 默认为 copyFile", function () {
|
|
142
|
+
cleanDir(DEST_PATH);
|
|
143
|
+
|
|
144
|
+
// 不指定 fileAction 和 defaultAction,未知扩展名应使用 copyFile 作为兜底
|
|
145
|
+
const jsFile = path.join(SRC_PATH, "test-default-action.js");
|
|
146
|
+
fs.writeFileSync(jsFile, "console.log('test');");
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
generateCode({
|
|
150
|
+
sourceDir: SRC_PATH, outDir: DEST_PATH, projectPath: PROJECT_PATH,
|
|
151
|
+
fileAction() {
|
|
152
|
+
return undefined; // 不提供任何 action
|
|
153
|
+
},
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
// copyFile 应该将 .js 文件复制到输出目录
|
|
157
|
+
const outFile = path.resolve(DEST_PATH, "test-default-action.js");
|
|
158
|
+
expect(fs.existsSync(outFile)).toBe(true);
|
|
159
|
+
} finally {
|
|
160
|
+
// 清理临时文件
|
|
161
|
+
if (fs.existsSync(jsFile)) fs.unlinkSync(jsFile);
|
|
162
|
+
const outFile = path.resolve(DEST_PATH, "test-default-action.js");
|
|
163
|
+
if (fs.existsSync(outFile)) fs.unlinkSync(outFile);
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
describe("isIgnoredFile", function () {
|
|
168
|
+
|
|
169
|
+
test(".spec.ts 文件应该被忽略", function () {
|
|
170
|
+
let filePath = "D:\\project\\src\\app.controller.spec.ts";
|
|
171
|
+
let ignored = isIgnoredFile(filePath);
|
|
172
|
+
expect(ignored).toBe(true);
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
test(".test.ts 文件应该被忽略", function () {
|
|
176
|
+
let filePath = "D:\\project\\src\\app.controller.test.ts";
|
|
177
|
+
let ignored = isIgnoredFile(filePath);
|
|
178
|
+
expect(ignored).toBe(true);
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
test(".d.ts 文件应该被忽略", function () {
|
|
182
|
+
let filePath = "D:\\project\\src\\app.d.ts";
|
|
183
|
+
let ignored = isIgnoredFile(filePath);
|
|
184
|
+
expect(ignored).toBe(true);
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
test("普通 .ts 文件不应被忽略", function () {
|
|
188
|
+
let filePath = "D:\\project\\src\\app.controller.ts";
|
|
189
|
+
let ignored = isIgnoredFile(filePath);
|
|
190
|
+
expect(ignored).toBe(false);
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
test("空参数应抛出异常", function () {
|
|
194
|
+
expect(() => isIgnoredFile("")).toThrow();
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
test("watchDirectory test, 修改文件应该触发回调, 删除文件不应该触发回调", async function () {
|
|
200
|
+
let filePath = path.join(SRC_PATH, "test.txt");
|
|
201
|
+
filePath = filePath.replace(/\\/g, "/");
|
|
202
|
+
fs.writeFileSync(filePath, "test");
|
|
203
|
+
const fileAction = jest.fn();
|
|
204
|
+
|
|
205
|
+
setTimeout(() => {
|
|
206
|
+
let executedPaths: string[] = [];
|
|
207
|
+
watchDirectory({
|
|
208
|
+
sourceDir: SRC_PATH, outDir: DEST_PATH, projectPath: PROJECT_PATH,
|
|
209
|
+
fileAction: () => {
|
|
210
|
+
return fileAction;
|
|
211
|
+
},
|
|
212
|
+
callback(filePath: string) {
|
|
213
|
+
executedPaths.push(filePath);
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
}, 0);
|
|
217
|
+
|
|
218
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
219
|
+
// 修改文件
|
|
220
|
+
fs.writeFileSync(filePath, "test2");
|
|
221
|
+
|
|
222
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
223
|
+
expect(fileAction.mock.calls.length).toBe(1);
|
|
224
|
+
expect(fileAction.mock.calls[0][0]).toBe(filePath);
|
|
225
|
+
|
|
226
|
+
const calltimes = fileAction.mock.calls.length;
|
|
227
|
+
setTimeout(() => {
|
|
228
|
+
// 删除文件
|
|
229
|
+
fs.unlinkSync(filePath);
|
|
230
|
+
}, 1000);
|
|
231
|
+
|
|
232
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
233
|
+
expect(fileAction.mock.calls.length).toBe(calltimes);
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
})
|
package/src/modules/compile.ts
CHANGED
|
@@ -84,11 +84,15 @@ type Options = {
|
|
|
84
84
|
sourceDir: string, outDir: string, projectPath: string,
|
|
85
85
|
skipFiles?: RegExp[],
|
|
86
86
|
fileAction?: (fileName: string) => FileAction | undefined,
|
|
87
|
-
callback?: Callback
|
|
87
|
+
callback?: Callback,
|
|
88
|
+
defaultAction?: FileAction
|
|
88
89
|
}
|
|
89
90
|
function generateCodeByOptions(options: Options) {
|
|
90
91
|
|
|
91
|
-
let { sourceDir, outDir, projectPath, skipFiles, fileAction: fileActions, callback } = options;
|
|
92
|
+
let { sourceDir, outDir, projectPath, skipFiles, fileAction: fileActions, callback, defaultAction } = options;
|
|
93
|
+
|
|
94
|
+
// if (!defaultAction)
|
|
95
|
+
// defaultAction = copyFile;
|
|
92
96
|
|
|
93
97
|
|
|
94
98
|
if (!sourceDir) throw errors.argumentNull("sourceDir");
|
|
@@ -116,7 +120,7 @@ function generateCodeByOptions(options: Options) {
|
|
|
116
120
|
continue;
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
let action = fileActions?.(filePath) || configs.fileActions[ext];
|
|
123
|
+
let action = fileActions?.(filePath) || configs.fileActions[ext] || defaultAction;
|
|
120
124
|
if (action) {
|
|
121
125
|
action(filePath, outDir, projectPath);
|
|
122
126
|
if (callback) {
|
|
@@ -130,15 +134,18 @@ function generateCodeByOptions(options: Options) {
|
|
|
130
134
|
let fullPath = path.join(sourceDir, dir);
|
|
131
135
|
let outDirPath = path.join(outDir, dir);
|
|
132
136
|
if (fs.statSync(fullPath).isDirectory()) {
|
|
133
|
-
generateCodeByOptions({ sourceDir: fullPath, outDir: outDirPath, projectPath: projectPath, skipFiles, fileAction: fileActions, callback });
|
|
137
|
+
generateCodeByOptions({ sourceDir: fullPath, outDir: outDirPath, projectPath: projectPath, skipFiles, fileAction: fileActions, callback, defaultAction });
|
|
134
138
|
}
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
function watchDirectoryByOptions(options: Options) {
|
|
139
|
-
let { sourceDir, outDir, projectPath, skipFiles, fileAction: fileActions, callback } = options;
|
|
143
|
+
let { sourceDir, outDir, projectPath, skipFiles, fileAction: fileActions, callback, defaultAction } = options;
|
|
144
|
+
|
|
145
|
+
if (!defaultAction)
|
|
146
|
+
defaultAction = copyFile;
|
|
140
147
|
|
|
141
|
-
watch(sourceDir, { recursive: true }, async (evt, name) => {
|
|
148
|
+
watch(sourceDir, { recursive: true }, async (evt: "update" | "remove", name: string) => {
|
|
142
149
|
const filePath = name.replace(/\\/g, "/");
|
|
143
150
|
sourceDir = sourceDir.replace(/\\/g, "/");
|
|
144
151
|
outDir = outDir.replace(/\\/g, "/");
|
|
@@ -155,7 +162,7 @@ function watchDirectoryByOptions(options: Options) {
|
|
|
155
162
|
return;
|
|
156
163
|
}
|
|
157
164
|
|
|
158
|
-
let action = fileActions?.(filePath) || configs.fileActions[ext];
|
|
165
|
+
let action = fileActions?.(filePath) || configs.fileActions[ext] || defaultAction;
|
|
159
166
|
if (!action) {
|
|
160
167
|
return;
|
|
161
168
|
}
|
package/src/modules/configs.ts
CHANGED
|
@@ -2,8 +2,7 @@ import { FileAction } from "../types";
|
|
|
2
2
|
import scssCompile from "./actions/scss-compile";
|
|
3
3
|
import lessCompile from "./actions/less-compile";
|
|
4
4
|
import { create as createBielCompiler } from "./actions/babel-compile";
|
|
5
|
-
import
|
|
6
|
-
import ts from "typescript";
|
|
5
|
+
import copyFile from "./actions/copy-file";
|
|
7
6
|
|
|
8
7
|
// const skipFiles = ["\\S+\\.d\\.tsx?$", "\\S+\\.test\\.tsx?$", "\\S+\\.spec\\.tsx?$"]
|
|
9
8
|
|
|
@@ -12,9 +11,10 @@ const fileActions: Record<string, FileAction> = {
|
|
|
12
11
|
".tsx": createBielCompiler(),
|
|
13
12
|
".scss": scssCompile,
|
|
14
13
|
".less": lessCompile,
|
|
14
|
+
".map": copyFile,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
class
|
|
17
|
+
export class Config {
|
|
18
18
|
fileActions: Record<string, FileAction> = fileActions;
|
|
19
19
|
skipFiles: Record<string, RegExp[]> = {
|
|
20
20
|
".tsx": [/\.d\.tsx?$/, /\.test\.tsx?$/, /\.spec\.tsx?$/],
|
|
@@ -24,6 +24,5 @@ class Options {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
export default (global as any)[NAME] as Options;
|
|
27
|
+
const config = new Config();
|
|
28
|
+
export default config;
|
package/src/modules/errors.ts
CHANGED
|
@@ -21,6 +21,14 @@ class Errors extends BaseErrors {
|
|
|
21
21
|
error.name = Errors.prototype.invalidBabelConfigExtension.name;
|
|
22
22
|
return error;
|
|
23
23
|
}
|
|
24
|
+
copyFileError(sourcePath: string, destPath: string, innerError?: Error) {
|
|
25
|
+
let error = new Error(`Failed to copy file from "${sourcePath}" to "${destPath}"`);
|
|
26
|
+
error.name = Errors.prototype.copyFileError.name;
|
|
27
|
+
if (innerError) {
|
|
28
|
+
error.cause = innerError;
|
|
29
|
+
}
|
|
30
|
+
return error;
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
export const errors = new Errors();
|