mm_machine 2.8.4 → 2.8.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.
- package/index.js +13 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -86,10 +86,10 @@ class Manager extends Mod {
|
|
|
86
86
|
*/
|
|
87
87
|
use_snapshot: true,
|
|
88
88
|
/**
|
|
89
|
-
*
|
|
89
|
+
* 快照文件路径,留空则自动生成到 cache/snapshot/ 目录下
|
|
90
90
|
* @type {string}
|
|
91
91
|
*/
|
|
92
|
-
snapshot_file: '
|
|
92
|
+
snapshot_file: ''
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
/**
|
|
@@ -479,12 +479,19 @@ Manager.prototype._findFiles = async function (dir) {
|
|
|
479
479
|
|
|
480
480
|
/**
|
|
481
481
|
* 获取快照文件路径
|
|
482
|
+
* 默认统一放到 /cache/snapshot/ 目录,文件名由类名+配置名组成
|
|
482
483
|
* @returns {string} 快照文件完整路径
|
|
483
484
|
*/
|
|
484
485
|
Manager.prototype.getSnapshotPath = function () {
|
|
485
|
-
var snapshot_file = this.config.snapshot_file
|
|
486
|
-
|
|
487
|
-
|
|
486
|
+
var snapshot_file = this.config.snapshot_file;
|
|
487
|
+
if (!snapshot_file) {
|
|
488
|
+
var class_name = this.constructor.name.toLowerCase();
|
|
489
|
+
var name = this.config.name || 'default';
|
|
490
|
+
snapshot_file = `./cache/snapshot/${class_name}_${name}.json`;
|
|
491
|
+
// 确保目录存在
|
|
492
|
+
snapshot_file.addDir();
|
|
493
|
+
}
|
|
494
|
+
return snapshot_file.fullname();
|
|
488
495
|
};
|
|
489
496
|
|
|
490
497
|
/**
|
|
@@ -874,7 +881,7 @@ Manager.prototype._runMod = async function (mod, method, ...params) {
|
|
|
874
881
|
/**
|
|
875
882
|
* 初始化管理器
|
|
876
883
|
*/
|
|
877
|
-
Manager.prototype._initManager = function () {};
|
|
884
|
+
Manager.prototype._initManager = function () { };
|
|
878
885
|
|
|
879
886
|
/**
|
|
880
887
|
* 获取公共模块目录
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.5",
|
|
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": {
|