mm_machine 1.4.5 → 1.4.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/index.js +13 -12
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -78,7 +78,7 @@ class Item {
|
|
|
78
78
|
* @param {Object} config 配置
|
|
79
79
|
*/
|
|
80
80
|
Item.prototype.set_config = function(config){
|
|
81
|
-
this.config = conf(Object.assign(this.config, config));
|
|
81
|
+
this.config = conf(Object.assign(this.config, config || {}));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -113,16 +113,15 @@ Item.prototype.remove_module = function(module) {
|
|
|
113
113
|
* @description 加载配置对象
|
|
114
114
|
* @param {Object} obj 配置对象
|
|
115
115
|
*/
|
|
116
|
-
Item.prototype.loadObj = function(
|
|
117
|
-
|
|
118
|
-
var f = this.config.func_file;
|
|
116
|
+
Item.prototype.loadObj = function(config) {
|
|
117
|
+
var f = config.func_file;
|
|
119
118
|
if (f) {
|
|
120
119
|
var file = f.fullname(this.dir);
|
|
121
120
|
if (file.hasFile()) {
|
|
122
121
|
this.remove_module(file);
|
|
123
122
|
var cs = require(file);
|
|
124
123
|
if (cs) {
|
|
125
|
-
var name =
|
|
124
|
+
var name = config.func_name;
|
|
126
125
|
if (name) {
|
|
127
126
|
this.main = cs[name];
|
|
128
127
|
} else {
|
|
@@ -158,6 +157,10 @@ Item.prototype.loadFile = function(file) {
|
|
|
158
157
|
obj = text.toJson();
|
|
159
158
|
} else {
|
|
160
159
|
this.new_config(f);
|
|
160
|
+
var text = f.loadText();
|
|
161
|
+
if (text) {
|
|
162
|
+
obj = text.toJson();
|
|
163
|
+
}
|
|
161
164
|
}
|
|
162
165
|
this.filename = f;
|
|
163
166
|
return obj;
|
|
@@ -219,16 +222,14 @@ Item.prototype.removeFile = function() {
|
|
|
219
222
|
* @param {Object|String} cg 配置对象或配置路径
|
|
220
223
|
*/
|
|
221
224
|
Item.prototype.load = function(cg) {
|
|
222
|
-
var
|
|
223
|
-
if (!cg) {
|
|
224
|
-
cg = this.extensions;
|
|
225
|
-
}
|
|
225
|
+
var config;
|
|
226
226
|
if (typeof(cg) === "string") {
|
|
227
|
-
|
|
227
|
+
config = this.loadFile(cg);
|
|
228
228
|
} else {
|
|
229
|
-
|
|
229
|
+
config = cg;
|
|
230
230
|
}
|
|
231
|
-
this.
|
|
231
|
+
this.set_config(config);
|
|
232
|
+
this.loadObj(config);
|
|
232
233
|
};
|
|
233
234
|
|
|
234
235
|
/**
|