mm_machine 3.3.5 → 3.3.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.
- package/lib/manager.js +13 -12
- package/package.json +1 -1
package/lib/manager.js
CHANGED
|
@@ -131,6 +131,15 @@ Manager.prototype.getInfos = function () {
|
|
|
131
131
|
return this._getInfos();
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* 获取模块信息
|
|
136
|
+
* @param {string} name 模块名
|
|
137
|
+
* @returns {object|null} 模块配置对象
|
|
138
|
+
*/
|
|
139
|
+
Manager.prototype.getInfo = function (name) {
|
|
140
|
+
return this.infos.getObj({ name });
|
|
141
|
+
};
|
|
142
|
+
|
|
134
143
|
/**
|
|
135
144
|
* 获取所有模块对象
|
|
136
145
|
* @param {string} keyword 查询关键词,判断name、title、description之一是否包含关键词,包含的才返回
|
|
@@ -290,16 +299,9 @@ Manager.prototype.newMod = function (config_file, config, script) {
|
|
|
290
299
|
* @returns {object} 模块对象
|
|
291
300
|
*/
|
|
292
301
|
Manager.prototype.regMod = function (config_file, config = {}, script = {}) {
|
|
293
|
-
let
|
|
294
|
-
|
|
295
|
-
let mod = this.newMod(config_file, cg, script);
|
|
302
|
+
let mod = this.newMod(config_file, config, script);
|
|
296
303
|
if (!mod) return null;
|
|
297
|
-
|
|
298
|
-
// 模块已存在时不替换内存实例,避免破坏已初始化的模块
|
|
299
|
-
if (!this.getMod(mod.config.name)) {
|
|
300
|
-
this.setMod(mod.config.name, mod);
|
|
301
|
-
}
|
|
302
|
-
|
|
304
|
+
this.setMod(mod.config.name, mod);
|
|
303
305
|
let info = { ...mod.config, config_file: config_file };
|
|
304
306
|
this.infos.push(info);
|
|
305
307
|
return mod;
|
|
@@ -955,7 +957,7 @@ Manager.prototype.createFile = function (config, file) {
|
|
|
955
957
|
if (!config.description) {
|
|
956
958
|
throw new TypeError('模块描述不能为空');
|
|
957
959
|
}
|
|
958
|
-
if (this.
|
|
960
|
+
if (this.getInfo(config.name)) {
|
|
959
961
|
throw new Error(`创建失败,原因:模块${config.name}已存在`);
|
|
960
962
|
}
|
|
961
963
|
let mod = new this.Drive(config, this);
|
|
@@ -980,8 +982,7 @@ Manager.prototype.createFile = function (config, file) {
|
|
|
980
982
|
*/
|
|
981
983
|
Manager.prototype.create = function (config, file = '') {
|
|
982
984
|
let f = this.createFile(config, file);
|
|
983
|
-
|
|
984
|
-
return mod;
|
|
985
|
+
return this.regMod(f, config);
|
|
985
986
|
};
|
|
986
987
|
|
|
987
988
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.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": {
|