mm_machine 1.9.3 → 1.9.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.
Files changed (4) hide show
  1. package/index.js +19 -19
  2. package/item.js +11 -1
  3. package/package.json +1 -1
  4. package/test.js +1 -1
package/index.js CHANGED
@@ -78,10 +78,10 @@ Index.prototype.load_item = async function(dir, cg, file) {
78
78
  var drive = new this.Drive(dir, this.dir_base.fullname());
79
79
  drive.mode = this.mode;
80
80
  if (cg) {
81
- await drive.run('load_config', file, cg.name);
82
- await drive.run('set_config', cg);
81
+ await drive.exec('load_config', file, cg.name);
82
+ await drive.exec('set_config', cg);
83
83
  } else {
84
- await drive.run('load_config', file);
84
+ await drive.exec('load_config', file);
85
85
  }
86
86
  this.list.push(drive);
87
87
  return drive;
@@ -195,12 +195,12 @@ Index.prototype.update_config_have = async function(dir) {
195
195
  for (var n = 0; n < lt.length; n++) {
196
196
  var cg = lt[n];
197
197
  if (cg.name == o.config.name) {
198
- await o.run('set_config', cg);
198
+ await o.exec('set_config', cg);
199
199
  continue;
200
200
  }
201
201
  }
202
202
  } else {
203
- await o.run('set_config', config);
203
+ await o.exec('set_config', config);
204
204
  }
205
205
  }
206
206
  }
@@ -230,7 +230,7 @@ Index.prototype.update_script = async function() {
230
230
  for (var i = 0; i < list.length; i++) {
231
231
  var o = list[i];
232
232
  if (o.config.state === 1) {
233
- await o.run('load');
233
+ await o.exec('load');
234
234
  }
235
235
  }
236
236
  }
@@ -391,7 +391,7 @@ Index.prototype.load = async function(name) {
391
391
  var o = this.get(name);
392
392
  var file = null;
393
393
  if (o) {
394
- await o.run('load');
394
+ await o.exec('load');
395
395
  file = o.filename;
396
396
  }
397
397
  return file;
@@ -407,7 +407,7 @@ Index.prototype.unload = async function(name, remove) {
407
407
  var o = this.del(name, remove);
408
408
  var file = null;
409
409
  if (o) {
410
- await o.run('unload', remove);
410
+ await o.exec('unload', remove);
411
411
  file = o.filename;
412
412
  }
413
413
  return file;
@@ -421,7 +421,7 @@ Index.prototype.unload = async function(name, remove) {
421
421
  Index.prototype.reload = async function(name) {
422
422
  var o = this.get(name);
423
423
  if (o) {
424
- await o.run('reload');
424
+ await o.exec('reload');
425
425
  return o.filename;
426
426
  }
427
427
  return '没有找到模块';
@@ -468,14 +468,14 @@ Index.prototype.run = async function(name, method, ...params) {
468
468
  if (name) {
469
469
  var o = await this.get(name);
470
470
  if (o && o.config.state === 1) {
471
- var ret = o.run(method, ...params);
471
+ var ret = o.exec(method, ...params);
472
472
  if (util.types.isPromise(ret)) {
473
473
  result = await ret;
474
474
  } else {
475
475
  result = ret;
476
476
  }
477
477
  if (this.mode >= 4) {
478
- o.run('reload');
478
+ o.exec('reload');
479
479
  }
480
480
  }
481
481
  } else if (name === null) {
@@ -483,14 +483,14 @@ Index.prototype.run = async function(name, method, ...params) {
483
483
  for (var i = 0; i < lt.length; i++) {
484
484
  var o = lt[i];
485
485
  if (o.config.state === 1) {
486
- var ret = o.run(method, ...params);
486
+ var ret = o.exec(method, ...params);
487
487
  if (util.types.isPromise(ret)) {
488
488
  result = await ret;
489
489
  } else {
490
490
  result = ret;
491
491
  }
492
492
  if (this.mode >= 4) {
493
- o.run('reload');
493
+ o.exec('reload');
494
494
  }
495
495
  }
496
496
  }
@@ -511,16 +511,16 @@ Index.prototype.exec = async function(name, method, ...params) {
511
511
  var o = await this.get(name);
512
512
  if (o) {
513
513
  if (!o.complete) {
514
- await o.run('load');
514
+ await o.exec('load');
515
515
  }
516
- var ret = o.run(method, ...params);
516
+ var ret = o.exec(method, ...params);
517
517
  if (util.types.isPromise(ret)) {
518
518
  result = await ret;
519
519
  } else {
520
520
  result = ret;
521
521
  }
522
522
  if (this.mode >= 4) {
523
- await o.run('reload');
523
+ await o.exec('reload');
524
524
  }
525
525
  }
526
526
  } else if (name === null) {
@@ -528,16 +528,16 @@ Index.prototype.exec = async function(name, method, ...params) {
528
528
  for (var i = 0; i < lt.length; i++) {
529
529
  var o = lt[i];
530
530
  if (!o.complete) {
531
- await o.run('load');
531
+ await o.exec('load');
532
532
  }
533
- var ret = o.run(method, ...params);
533
+ var ret = o.exec(method, ...params);
534
534
  if (util.types.isPromise(ret)) {
535
535
  result = await ret;
536
536
  } else {
537
537
  result = ret;
538
538
  }
539
539
  if (this.mode >= 4) {
540
- await o.run('reload');
540
+ await o.exec('reload');
541
541
  }
542
542
  }
543
543
  }
package/item.js CHANGED
@@ -185,6 +185,8 @@ Item.prototype.load_script = function(file, name = "") {
185
185
  if (!file.hasFile()) {
186
186
  this.new_script(file);
187
187
  }
188
+ } else {
189
+ return;
188
190
  }
189
191
  }
190
192
  if (!name) {
@@ -411,13 +413,21 @@ Item.prototype.main = async function(...params) {
411
413
  return null;
412
414
  };
413
415
 
416
+ /**
417
+ * 运行
418
+ * @param {Object} params 参数集合
419
+ */
420
+ Item.prototype.run = async function(...params) {
421
+ return await this.exec("main", ...params);
422
+ }
423
+
414
424
  /**
415
425
  * 调用函数
416
426
  * @param {String} method 函数名
417
427
  * @param {Object} params 参数集合
418
428
  * @return {Object} 执行结果
419
429
  */
420
- Item.prototype.run = async function(method, ...params) {
430
+ Item.prototype.exec = async function(method, ...params) {
421
431
  if (this[method]) {
422
432
  var ret;
423
433
  if (this[method + "_before"]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/test.js CHANGED
@@ -107,7 +107,7 @@ async function demo() {
107
107
  }
108
108
  var plug = engine.get("demo3");
109
109
  if (plug) {
110
- var ret = await plug.run('main');
110
+ var ret = await plug.run();
111
111
  console.log("查看变化3", plug.config);
112
112
  }
113
113
  n++;