file-lane 2.0.6-beta.13 → 2.0.6-beta.15

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.js CHANGED
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.error.cause.js");
8
+ require("core-js/modules/es.array.push.js");
7
9
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
10
  var _chokidar = _interopRequireDefault(require("chokidar"));
9
11
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
@@ -88,7 +90,7 @@ class FileLane {
88
90
  if (!fileList || !fileList.length) {
89
91
  return;
90
92
  }
91
- if (params?.watch) {
93
+ if (params !== null && params !== void 0 && params.watch) {
92
94
  this.watch();
93
95
  }
94
96
  await this.build({
@@ -187,7 +189,7 @@ class FileLane {
187
189
  const timeStart = Date.now();
188
190
  this.initCompilation(trigger);
189
191
  this.building = true;
190
- onBuildStart?.();
192
+ onBuildStart === null || onBuildStart === void 0 || onBuildStart();
191
193
  try {
192
194
  await this.complyBeforeCompile();
193
195
  this.triggerPlugins(new _CompilationEvent.default(_CompilationEvent.default.PROJECT_START));
@@ -203,9 +205,10 @@ class FileLane {
203
205
  this.triggerPlugins(new _CompilationEvent.default(_CompilationEvent.default.FLLOW_WORK_END));
204
206
  const costTime = Date.now() - timeStart;
205
207
  if (onBuildSuccess) {
208
+ var _this$compilation;
206
209
  onBuildSuccess({
207
210
  costTime,
208
- info: this.compilation?.info
211
+ info: (_this$compilation = this.compilation) === null || _this$compilation === void 0 ? void 0 : _this$compilation.info
209
212
  });
210
213
  } else {
211
214
  _sharedUtils.ColorConsole.success({
@@ -214,7 +217,7 @@ class FileLane {
214
217
  }
215
218
  } catch (error) {
216
219
  if (onBuildError) {
217
- onBuildError?.(error);
220
+ onBuildError === null || onBuildError === void 0 || onBuildError(error);
218
221
  } else {
219
222
  _sharedUtils.ColorConsole.throw(`ERROR: `, {
220
223
  word: 'build error'
@@ -236,7 +239,7 @@ class FileLane {
236
239
  compilation.trigger = trigger;
237
240
  compilation.triggerCount = ++this.triggerCount;
238
241
  compilation.info.trigger = trigger;
239
- plugins?.forEach(item => {
242
+ plugins === null || plugins === void 0 || plugins.forEach(item => {
240
243
  item.compilation = compilation;
241
244
  item.apply();
242
245
  });
@@ -290,10 +293,11 @@ class FileLane {
290
293
  * @returns
291
294
  */
292
295
  handlerLogs(logs, onError) {
293
- if (!logs?.length) {
296
+ var _this$events;
297
+ if (!(logs !== null && logs !== void 0 && logs.length)) {
294
298
  return;
295
299
  }
296
- const onLog = this.events?.onLog;
300
+ const onLog = (_this$events = this.events) === null || _this$events === void 0 ? void 0 : _this$events.onLog;
297
301
  if (onLog) {
298
302
  onLog(logs);
299
303
  } else {
@@ -303,7 +307,7 @@ class FileLane {
303
307
  }
304
308
  const hasError = logs.find(item => item.level && [_sharedUtils.Loglevel.ERROR, _sharedUtils.Loglevel.THROW].includes(item.level));
305
309
  if (hasError) {
306
- onError?.();
310
+ onError === null || onError === void 0 || onError();
307
311
  }
308
312
  }
309
313
  async writeFiles(fileList) {
@@ -30,14 +30,14 @@ class FileLaneCompilation extends _AsyncEventDispatcher.default {
30
30
  * 触发方式
31
31
  *
32
32
  */
33
- trigger = (() => _FileLaneTriggerType.default.START)();
33
+ trigger = _FileLaneTriggerType.default.START;
34
34
 
35
35
  /**
36
36
  * 触发次数
37
37
  */
38
38
  triggerCount = 0;
39
- info = (() => ({
39
+ info = {
40
40
  trigger: _FileLaneTriggerType.default.START
41
- }))();
41
+ };
42
42
  }
43
43
  var _default = exports.default = FileLaneCompilation;
@@ -4,8 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  class AsyncEventDispatcher {
8
- _eventMap = (() => new Map())();
9
+ _eventMap = new Map();
9
10
  async dispatch(event) {
10
11
  return new Promise(resolve => {
11
12
  const {
@@ -18,8 +18,7 @@ class FileLaneUtil {
18
18
  * @param readContent 是否读取文件内容以设置 content 的值,默认 false
19
19
  * @returns
20
20
  */
21
- static pathToFileParam(path) {
22
- let readContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
21
+ static pathToFileParam(path, readContent = false) {
23
22
  let content = '';
24
23
  if (readContent && _fsExtra.default.existsSync(path)) {
25
24
  const stats = _fsExtra.default.statSync(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-lane",
3
- "version": "2.0.6-beta.13",
3
+ "version": "2.0.6-beta.15",
4
4
  "description": "File conversion tool, can be one-to-one, one to N, N to one",
5
5
  "keywords": [
6
6
  "file",
@@ -20,12 +20,12 @@
20
20
  "test": "node ./__tests__/file-lane.test.js"
21
21
  },
22
22
  "dependencies": {
23
- "@aiot-toolkit/shared-utils": "2.0.6-beta.13",
23
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.15",
24
24
  "chokidar": "^3.6.0",
25
25
  "fs-extra": "^11.2.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/fs-extra": "^11.0.4"
29
29
  },
30
- "gitHead": "a565cdee8e827a67b4043d9f872b7a6d933630db"
30
+ "gitHead": "8a927aec513af6d004f88e21d85bba0ef2dcac90"
31
31
  }