mm_machine 2.5.8 → 2.5.9
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 +16 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -920,9 +920,10 @@ Manager.prototype.offEvent = function (event) {
|
|
|
920
920
|
/**
|
|
921
921
|
* 创建模块
|
|
922
922
|
* @param {object} config 模块配置
|
|
923
|
+
* @param {string} file 模块文件路径
|
|
923
924
|
* @returns {string} 创建的模块文件路径
|
|
924
925
|
*/
|
|
925
|
-
Manager.prototype.createFile = function (config) {
|
|
926
|
+
Manager.prototype.createFile = function (config, file) {
|
|
926
927
|
if (!config.name) {
|
|
927
928
|
throw new TypeError('模块名称不能为空');
|
|
928
929
|
}
|
|
@@ -936,24 +937,28 @@ Manager.prototype.createFile = function (config) {
|
|
|
936
937
|
throw new Error(`创建失败,原因:模块${config.name}已存在`);
|
|
937
938
|
}
|
|
938
939
|
let mod = new this.Drive(config, this);
|
|
939
|
-
let
|
|
940
|
-
if (
|
|
941
|
-
|
|
942
|
-
|
|
940
|
+
let f = file;
|
|
941
|
+
if (!f) {
|
|
942
|
+
f = `${config.name}/${this.config.filename}`;
|
|
943
|
+
if (this.config.search_way === 'dir') {
|
|
944
|
+
let dir_name = this._getDirName();
|
|
945
|
+
f = `${dir_name}/${f}`;
|
|
946
|
+
}
|
|
943
947
|
}
|
|
944
|
-
|
|
945
|
-
mod.createConfigFile(
|
|
946
|
-
return
|
|
948
|
+
f = f.fullname(this.config.dir);
|
|
949
|
+
mod.createConfigFile(f, config);
|
|
950
|
+
return f;
|
|
947
951
|
};
|
|
948
952
|
|
|
949
953
|
/**
|
|
950
954
|
* 创建模块
|
|
951
955
|
* @param {object} config 模块配置
|
|
956
|
+
* @param {string} file 模块文件路径
|
|
952
957
|
* @returns {object} 创建的模块实例
|
|
953
958
|
*/
|
|
954
|
-
Manager.prototype.create = function (config) {
|
|
955
|
-
let
|
|
956
|
-
let mod = this.registerMod(
|
|
959
|
+
Manager.prototype.create = function (config, file = '') {
|
|
960
|
+
let f = this.createFile(config, file);
|
|
961
|
+
let mod = this.registerMod(f, config);
|
|
957
962
|
return mod;
|
|
958
963
|
};
|
|
959
964
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.9",
|
|
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": {
|