file-lane 2.0.3-beta.1 → 2.0.3-beta.2
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 +19 -27
- 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
|
/**
|
|
@@ -138,22 +145,14 @@ class FileLane {
|
|
|
138
145
|
}
|
|
139
146
|
return result;
|
|
140
147
|
}
|
|
141
|
-
|
|
142
|
-
process.exit();
|
|
143
|
-
}
|
|
144
|
-
stop() {
|
|
148
|
+
dispose() {
|
|
145
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
150
|
if (this.watcher) {
|
|
147
151
|
this.watcher.removeAllListeners();
|
|
148
152
|
yield this.watcher.close();
|
|
149
153
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
dispose() {
|
|
153
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
this.complyAfterWork();
|
|
155
|
-
yield this.stop();
|
|
156
|
-
this.cleanOutput();
|
|
154
|
+
yield this.complyAfterWork();
|
|
155
|
+
yield this.cleanOutput();
|
|
157
156
|
});
|
|
158
157
|
}
|
|
159
158
|
/**
|
|
@@ -179,14 +178,12 @@ class FileLane {
|
|
|
179
178
|
this.triggerPlugins(new CompilationEvent_1.default(CompilationEvent_1.default.FLLOW_WORK_START));
|
|
180
179
|
yield this.complyAfterCompile();
|
|
181
180
|
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
|
-
});
|
|
181
|
+
if (onBuildSuccess) {
|
|
182
|
+
onBuildSuccess === null || onBuildSuccess === void 0 ? void 0 : onBuildSuccess({
|
|
183
|
+
costTime: Date.now() - t1,
|
|
184
|
+
info: (_a = this.compilation) === null || _a === void 0 ? void 0 : _a.info
|
|
185
|
+
});
|
|
186
|
+
}
|
|
190
187
|
}
|
|
191
188
|
catch (error) {
|
|
192
189
|
if (onBuildError) {
|
|
@@ -195,10 +192,6 @@ class FileLane {
|
|
|
195
192
|
else {
|
|
196
193
|
shared_utils_1.ColorConsole.throw(`ERROR: `, { word: 'build error' }, `, ${error || 'unknown error'}`);
|
|
197
194
|
}
|
|
198
|
-
// 非监听模式,则结束任务
|
|
199
|
-
if (!this.watcher) {
|
|
200
|
-
process.exit();
|
|
201
|
-
}
|
|
202
195
|
}
|
|
203
196
|
});
|
|
204
197
|
}
|
|
@@ -396,7 +389,6 @@ class FileLane {
|
|
|
396
389
|
}
|
|
397
390
|
catch (error) {
|
|
398
391
|
shared_utils_1.ColorConsole.throw(`FollowWork: ${item.workerDescribe} error, ${error}`);
|
|
399
|
-
process.exit();
|
|
400
392
|
}
|
|
401
393
|
}
|
|
402
394
|
}
|
|
@@ -493,7 +485,7 @@ class FileLane {
|
|
|
493
485
|
*/
|
|
494
486
|
cleanOutput() {
|
|
495
487
|
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
-
shared_utils_1.FileUtil.del(FileLaneUtil_1.default.getOutputPath(this.context));
|
|
488
|
+
return shared_utils_1.FileUtil.del(FileLaneUtil_1.default.getOutputPath(this.context));
|
|
497
489
|
});
|
|
498
490
|
}
|
|
499
491
|
/**
|
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.2",
|
|
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.2",
|
|
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": "7776973f6a81d7f13eb330be8df5801d9143c83c"
|
|
32
32
|
}
|