mm_machine 2.9.5 → 2.9.6

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 (2) hide show
  1. package/mod.js +18 -5
  2. package/package.json +1 -1
package/mod.js CHANGED
@@ -120,12 +120,14 @@ Mod.prototype._loadCore = async function () {
120
120
  * @private
121
121
  */
122
122
  Mod.prototype._initCore = async function () {
123
+ // 如果已初始化,跳过
124
+ if (this.lifecycle_state === 'inited') {
125
+ return;
126
+ }
123
127
  if (this.lifecycle_state !== 'loaded') {
124
128
  throw new Error('模块未加载,无法初始化');
125
129
  }
126
130
 
127
- this.emit('init:before');
128
-
129
131
  try {
130
132
  var init_hook = this.getMethod('_init');
131
133
  if (init_hook) {
@@ -319,7 +321,8 @@ Mod.prototype.isLoaded = function () {
319
321
  */
320
322
  Mod.prototype.log = function (level, message) {
321
323
  var logger = this.getLogger ? this.getLogger() : console;
322
- var prefix = '[' + (this.constructor.name || 'Mod') + '.' + ((this.config && this.config.name) || '') + ']';
324
+ var prefix =
325
+ '[' + (this.constructor.name || 'Mod') + '.' + ((this.config && this.config.name) || '') + ']';
323
326
  if (logger[level]) {
324
327
  logger[level](prefix + ' ' + message);
325
328
  } else {
@@ -567,7 +570,12 @@ Mod.prototype.saveDatas = function () {
567
570
  var path = require('path');
568
571
  var file = (this.config && this.config.cache_file) || '';
569
572
  if (!file) {
570
- file = path.resolve(process.cwd(), 'cache', (this.config && this.config.name) || 'mod', 'data.json');
573
+ file = path.resolve(
574
+ process.cwd(),
575
+ 'cache',
576
+ (this.config && this.config.name) || 'mod',
577
+ 'data.json'
578
+ );
571
579
  }
572
580
  var dir = path.dirname(file);
573
581
  if (!fs.existsSync(dir)) {
@@ -585,7 +593,12 @@ Mod.prototype.loadDatas = function () {
585
593
  var path = require('path');
586
594
  var file = (this.config && this.config.cache_file) || '';
587
595
  if (!file) {
588
- file = path.resolve(process.cwd(), 'cache', (this.config && this.config.name) || 'mod', 'data.json');
596
+ file = path.resolve(
597
+ process.cwd(),
598
+ 'cache',
599
+ (this.config && this.config.name) || 'mod',
600
+ 'data.json'
601
+ );
589
602
  }
590
603
  try {
591
604
  if (fs.existsSync(file)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "2.9.5",
3
+ "version": "2.9.6",
4
4
  "description": "A flexible Node.js plugin mechanism system for dynamic loading, management and execution of modules. Supports hot reload, lifecycle management, and modern JavaScript features.",
5
5
  "main": "index.js",
6
6
  "scripts": {