mm_machine 3.5.6 → 3.5.7

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/lib/manager.js +16 -8
  2. package/package.json +1 -1
package/lib/manager.js CHANGED
@@ -271,13 +271,16 @@ Manager.prototype.getMods = function () {
271
271
  */
272
272
  Manager.prototype._readModConfig = function (config_file, config = {}) {
273
273
  let mod_config = { ...config };
274
- if (mod_config.name || !config_file) {
275
- return mod_config;
274
+ if (!mod_config.name && config_file) {
275
+ let file_config = hasFile(config_file) ? this._getLoader().load(config_file) : null;
276
+ mod_config = { ...file_config, ...mod_config };
277
+ if (!mod_config.name) {
278
+ mod_config.name = basename(dirname(config_file));
279
+ }
276
280
  }
277
- let file_config = hasFile(config_file) ? this._getLoader().load(config_file) : null;
278
- mod_config = { ...file_config, ...mod_config };
279
- if (!mod_config.name) {
280
- mod_config.name = basename(dirname(config_file));
281
+ // 驱动目录默认为配置文件所在目录,供子类解析主脚本与参数、SQL配置的相对路径
282
+ if (!mod_config.dir && config_file) {
283
+ mod_config.dir = dirname(config_file);
281
284
  }
282
285
  return mod_config;
283
286
  };
@@ -305,9 +308,14 @@ Manager.prototype.newMod = function (config_file, config, script) {
305
308
  }
306
309
  mod.mode = this.config.mode;
307
310
 
311
+ // 仅 Drive 子类提供配置文件应用与热更新能力,Mod 子类(如 api、event、plugin)构造时已持有完整配置
308
312
  if (mod_config && config_file) {
309
- mod.applyConfig(config_file, mod_config);
310
- mod.watchConfig(config_file);
313
+ if (typeof mod.applyConfig === 'function') {
314
+ mod.applyConfig(config_file, mod_config);
315
+ }
316
+ if (typeof mod.watchConfig === 'function') {
317
+ mod.watchConfig(config_file);
318
+ }
311
319
  }
312
320
 
313
321
  if (script) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "3.5.6",
3
+ "version": "3.5.7",
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": {