file-lane 2.0.3-beta.1 → 2.0.3-beta.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.
- package/lib/FileLane.d.ts +2 -2
- package/lib/FileLane.js +41 -33
- package/package.json +3 -3
package/lib/FileLane.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare class FileLane<O = any> {
|
|
|
44
44
|
* @param compilerOption 编译参数,不同语言的项目具有的参数不同,即使同一项目开发者也会设置不同的参数
|
|
45
45
|
*/
|
|
46
46
|
constructor(config: IFileLaneConfig<O>, projectPath?: string, compilerOption?: O | undefined, events?: IFileLaneEvents | undefined);
|
|
47
|
+
private addProcessListener;
|
|
47
48
|
/**
|
|
48
49
|
* 运行
|
|
49
50
|
* @param params
|
|
@@ -58,9 +59,8 @@ declare class FileLane<O = any> {
|
|
|
58
59
|
watch?: boolean;
|
|
59
60
|
}): Promise<void>;
|
|
60
61
|
private validateConfig;
|
|
61
|
-
private
|
|
62
|
+
private processBeforeExitHandler;
|
|
62
63
|
private sigintHandler;
|
|
63
|
-
stop(): Promise<void>;
|
|
64
64
|
dispose(): Promise<void>;
|
|
65
65
|
/**
|
|
66
66
|
*
|
package/lib/FileLane.js
CHANGED
|
@@ -61,11 +61,18 @@ class FileLane {
|
|
|
61
61
|
this.events = events;
|
|
62
62
|
this.changeFileList = [];
|
|
63
63
|
this.triggerCount = 0;
|
|
64
|
-
this.
|
|
64
|
+
this.processBeforeExitHandler = () => {
|
|
65
65
|
this.dispose();
|
|
66
66
|
};
|
|
67
|
+
this.sigintHandler = () => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
yield this.dispose();
|
|
69
|
+
process.exit();
|
|
70
|
+
});
|
|
67
71
|
this.context = FileLaneUtil_1.default.createContext(config.output, projectPath);
|
|
68
|
-
|
|
72
|
+
this.addProcessListener();
|
|
73
|
+
}
|
|
74
|
+
addProcessListener() {
|
|
75
|
+
process.on('beforeExit', this.processBeforeExitHandler);
|
|
69
76
|
process.on('SIGINT', this.sigintHandler);
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
@@ -77,7 +84,14 @@ class FileLane {
|
|
|
77
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
85
|
const errorList = this.validateConfig();
|
|
79
86
|
if (errorList && errorList.length) {
|
|
80
|
-
|
|
87
|
+
this.handlerLogs([
|
|
88
|
+
{
|
|
89
|
+
level: shared_utils_1.Loglevel.ERROR,
|
|
90
|
+
message: `### file-lane ### ${errorList.map((item, index) => `${index + 1}. ${item}`).join('\r\n')}`
|
|
91
|
+
}
|
|
92
|
+
], () => {
|
|
93
|
+
throw new Error(`validate error`);
|
|
94
|
+
});
|
|
81
95
|
return;
|
|
82
96
|
}
|
|
83
97
|
yield this.complyBeforeWorks();
|
|
@@ -138,22 +152,14 @@ class FileLane {
|
|
|
138
152
|
}
|
|
139
153
|
return result;
|
|
140
154
|
}
|
|
141
|
-
|
|
142
|
-
process.exit();
|
|
143
|
-
}
|
|
144
|
-
stop() {
|
|
155
|
+
dispose() {
|
|
145
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
157
|
if (this.watcher) {
|
|
147
158
|
this.watcher.removeAllListeners();
|
|
148
159
|
yield this.watcher.close();
|
|
149
160
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
dispose() {
|
|
153
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
this.complyAfterWork();
|
|
155
|
-
yield this.stop();
|
|
156
|
-
this.cleanOutput();
|
|
161
|
+
yield this.complyAfterWork();
|
|
162
|
+
yield this.cleanOutput();
|
|
157
163
|
});
|
|
158
164
|
}
|
|
159
165
|
/**
|
|
@@ -179,14 +185,12 @@ class FileLane {
|
|
|
179
185
|
this.triggerPlugins(new CompilationEvent_1.default(CompilationEvent_1.default.FLLOW_WORK_START));
|
|
180
186
|
yield this.complyAfterCompile();
|
|
181
187
|
this.triggerPlugins(new CompilationEvent_1.default(CompilationEvent_1.default.FLLOW_WORK_END));
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
style: shared_utils_1.ColorConsole.getStyle(shared_utils_1.Loglevel.SUCCESS)
|
|
189
|
-
});
|
|
188
|
+
if (onBuildSuccess) {
|
|
189
|
+
onBuildSuccess === null || onBuildSuccess === void 0 ? void 0 : onBuildSuccess({
|
|
190
|
+
costTime: Date.now() - t1,
|
|
191
|
+
info: (_a = this.compilation) === null || _a === void 0 ? void 0 : _a.info
|
|
192
|
+
});
|
|
193
|
+
}
|
|
190
194
|
}
|
|
191
195
|
catch (error) {
|
|
192
196
|
if (onBuildError) {
|
|
@@ -195,10 +199,6 @@ class FileLane {
|
|
|
195
199
|
else {
|
|
196
200
|
shared_utils_1.ColorConsole.throw(`ERROR: `, { word: 'build error' }, `, ${error || 'unknown error'}`);
|
|
197
201
|
}
|
|
198
|
-
// 非监听模式,则结束任务
|
|
199
|
-
if (!this.watcher) {
|
|
200
|
-
process.exit();
|
|
201
|
-
}
|
|
202
202
|
}
|
|
203
203
|
});
|
|
204
204
|
}
|
|
@@ -279,7 +279,7 @@ class FileLane {
|
|
|
279
279
|
}
|
|
280
280
|
const hasError = logs.find((item) => item.level && [shared_utils_1.Loglevel.ERROR, shared_utils_1.Loglevel.THROW].includes(item.level));
|
|
281
281
|
if (hasError) {
|
|
282
|
-
onError();
|
|
282
|
+
onError === null || onError === void 0 ? void 0 : onError();
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
writeFiles(fileList) {
|
|
@@ -385,18 +385,27 @@ class FileLane {
|
|
|
385
385
|
if (afterCompile) {
|
|
386
386
|
for (let item of afterCompile) {
|
|
387
387
|
try {
|
|
388
|
-
|
|
388
|
+
this.handlerLogs([
|
|
389
|
+
{
|
|
390
|
+
level: shared_utils_1.Loglevel.INFO,
|
|
391
|
+
message: `FollowWork: ${item.workerDescribe} start`
|
|
392
|
+
}
|
|
393
|
+
]);
|
|
389
394
|
yield item.worker({
|
|
390
395
|
context: this.context,
|
|
391
396
|
config: this.config,
|
|
392
397
|
compilerOption: this.compilerOption,
|
|
393
398
|
compalition: this.compilation
|
|
394
399
|
});
|
|
395
|
-
|
|
400
|
+
this.handlerLogs([
|
|
401
|
+
{
|
|
402
|
+
level: shared_utils_1.Loglevel.INFO,
|
|
403
|
+
message: `FollowWork: ${item.workerDescribe} end`
|
|
404
|
+
}
|
|
405
|
+
]);
|
|
396
406
|
}
|
|
397
407
|
catch (error) {
|
|
398
|
-
|
|
399
|
-
process.exit();
|
|
408
|
+
throw new Error(`FollowWork: ${item.workerDescribe} error,`);
|
|
400
409
|
}
|
|
401
410
|
}
|
|
402
411
|
}
|
|
@@ -463,7 +472,6 @@ class FileLane {
|
|
|
463
472
|
};
|
|
464
473
|
watcher
|
|
465
474
|
.on('ready', () => {
|
|
466
|
-
shared_utils_1.ColorConsole.log(`### file-lane ### Initial scan complete. Ready for Watch.`);
|
|
467
475
|
watcher
|
|
468
476
|
.on('add', (path) => {
|
|
469
477
|
// 监听文件添加事件
|
|
@@ -493,7 +501,7 @@ class FileLane {
|
|
|
493
501
|
*/
|
|
494
502
|
cleanOutput() {
|
|
495
503
|
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
-
shared_utils_1.FileUtil.del(FileLaneUtil_1.default.getOutputPath(this.context));
|
|
504
|
+
return shared_utils_1.FileUtil.del(FileLaneUtil_1.default.getOutputPath(this.context));
|
|
497
505
|
});
|
|
498
506
|
}
|
|
499
507
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "file-lane",
|
|
3
|
-
"version": "2.0.3-beta.
|
|
3
|
+
"version": "2.0.3-beta.3",
|
|
4
4
|
"description": "File conversion tool, can be one-to-one, one to N, N to one",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test": "node ./__tests__/file-lane.test.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aiot-toolkit/shared-utils": "2.0.3-beta.
|
|
23
|
+
"@aiot-toolkit/shared-utils": "2.0.3-beta.3",
|
|
24
24
|
"chokidar": "^3.6.0",
|
|
25
25
|
"fs-extra": "^11.2.0",
|
|
26
26
|
"lodash": "^4.17.21"
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/fs-extra": "^11.0.4"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "a4cad870b23d9e4142d22e59aa5618d7f123e1ab"
|
|
32
32
|
}
|