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

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,8 +4,6 @@ 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");
9
7
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
10
8
  var _chokidar = _interopRequireDefault(require("chokidar"));
11
9
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
@@ -90,7 +88,7 @@ class FileLane {
90
88
  if (!fileList || !fileList.length) {
91
89
  return;
92
90
  }
93
- if (params !== null && params !== void 0 && params.watch) {
91
+ if (params?.watch) {
94
92
  this.watch();
95
93
  }
96
94
  await this.build({
@@ -189,7 +187,7 @@ class FileLane {
189
187
  const timeStart = Date.now();
190
188
  this.initCompilation(trigger);
191
189
  this.building = true;
192
- onBuildStart === null || onBuildStart === void 0 || onBuildStart();
190
+ onBuildStart?.();
193
191
  try {
194
192
  await this.complyBeforeCompile();
195
193
  this.triggerPlugins(new _CompilationEvent.default(_CompilationEvent.default.PROJECT_START));
@@ -205,10 +203,9 @@ class FileLane {
205
203
  this.triggerPlugins(new _CompilationEvent.default(_CompilationEvent.default.FLLOW_WORK_END));
206
204
  const costTime = Date.now() - timeStart;
207
205
  if (onBuildSuccess) {
208
- var _this$compilation;
209
206
  onBuildSuccess({
210
207
  costTime,
211
- info: (_this$compilation = this.compilation) === null || _this$compilation === void 0 ? void 0 : _this$compilation.info
208
+ info: this.compilation?.info
212
209
  });
213
210
  } else {
214
211
  _sharedUtils.ColorConsole.success({
@@ -217,7 +214,7 @@ class FileLane {
217
214
  }
218
215
  } catch (error) {
219
216
  if (onBuildError) {
220
- onBuildError === null || onBuildError === void 0 || onBuildError(error);
217
+ onBuildError?.(error);
221
218
  } else {
222
219
  _sharedUtils.ColorConsole.throw(`ERROR: `, {
223
220
  word: 'build error'
@@ -239,7 +236,7 @@ class FileLane {
239
236
  compilation.trigger = trigger;
240
237
  compilation.triggerCount = ++this.triggerCount;
241
238
  compilation.info.trigger = trigger;
242
- plugins === null || plugins === void 0 || plugins.forEach(item => {
239
+ plugins?.forEach(item => {
243
240
  item.compilation = compilation;
244
241
  item.apply();
245
242
  });
@@ -293,11 +290,10 @@ class FileLane {
293
290
  * @returns
294
291
  */
295
292
  handlerLogs(logs, onError) {
296
- var _this$events;
297
- if (!(logs !== null && logs !== void 0 && logs.length)) {
293
+ if (!logs?.length) {
298
294
  return;
299
295
  }
300
- const onLog = (_this$events = this.events) === null || _this$events === void 0 ? void 0 : _this$events.onLog;
296
+ const onLog = this.events?.onLog;
301
297
  if (onLog) {
302
298
  onLog(logs);
303
299
  } else {
@@ -307,7 +303,7 @@ class FileLane {
307
303
  }
308
304
  const hasError = logs.find(item => item.level && [_sharedUtils.Loglevel.ERROR, _sharedUtils.Loglevel.THROW].includes(item.level));
309
305
  if (hasError) {
310
- onError === null || onError === void 0 || onError();
306
+ onError?.();
311
307
  }
312
308
  }
313
309
  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,9 +4,8 @@ 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");
8
7
  class AsyncEventDispatcher {
9
- _eventMap = new Map();
8
+ _eventMap = (() => new Map())();
10
9
  async dispatch(event) {
11
10
  return new Promise(resolve => {
12
11
  const {
@@ -18,7 +18,8 @@ class FileLaneUtil {
18
18
  * @param readContent 是否读取文件内容以设置 content 的值,默认 false
19
19
  * @returns
20
20
  */
21
- static pathToFileParam(path, readContent = false) {
21
+ static pathToFileParam(path) {
22
+ let readContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
22
23
  let content = '';
23
24
  if (readContent && _fsExtra.default.existsSync(path)) {
24
25
  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.15",
3
+ "version": "2.0.6-beta.16",
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.15",
23
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.16",
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": "8a927aec513af6d004f88e21d85bba0ef2dcac90"
30
+ "gitHead": "6886b19268203a68f1bc232ef79248dffe3d9487"
31
31
  }