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.
Files changed (2) hide show
  1. package/index.js +13 -12
  2. 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(obj) {
117
- $.push(this.config, obj, true);
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 = this.config.func_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 obj;
223
- if (!cg) {
224
- cg = this.extensions;
225
- }
225
+ var config;
226
226
  if (typeof(cg) === "string") {
227
- obj = this.loadFile(cg);
227
+ config = this.loadFile(cg);
228
228
  } else {
229
- obj = cg;
229
+ config = cg;
230
230
  }
231
- this.loadObj(obj);
231
+ this.set_config(config);
232
+ this.loadObj(config);
232
233
  };
233
234
 
234
235
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_machine",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "这是超级美眉框架机制构建辅助模块,用于快速构建一个机制",
5
5
  "main": "index.js",
6
6
  "scripts": {