Skip to content

Commit ba9bcd0

Browse files
committed
feat(plugin): 添加插件读取 ykit.js 配置功能
1 parent 6d4bb50 commit ba9bcd0

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/models/Project.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,19 @@ var Project = function () {
154154
}
155155

156156
// 通过插件扩展配置
157-
_this3.plugins.map(function (pluginName) {
157+
_this3.plugins.map(function (pluginItem) {
158+
var pluginName = '';
159+
160+
if (typeof pluginItem === 'string') {
161+
pluginName = pluginItem;
162+
} else if ((typeof pluginItem === 'undefined' ? 'undefined' : _typeof(pluginItem)) === 'object') {
163+
pluginName = pluginItem.plugin ? pluginItem.plugin : '';
164+
_typeof(pluginItem.options) === 'object' && extend(options, pluginItem.options);
165+
} else {
166+
error('插件配置有误,请检查 ykit.js');
167+
process.exit(1);
168+
}
169+
158170
if (pluginName.indexOf(ykitConfigStartWith) === -1) {
159171
pluginName = ykitConfigStartWith + pluginName;
160172
}

src/models/Project.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,19 @@ class Project {
138138
}
139139

140140
// 通过插件扩展配置
141-
this.plugins.map((pluginName) => {
141+
this.plugins.map((pluginItem) => {
142+
let pluginName = '';
143+
144+
if(typeof pluginItem === 'string') {
145+
pluginName = pluginItem;
146+
} else if(typeof pluginItem === 'object') {
147+
pluginName = pluginItem.plugin ? pluginItem.plugin : '';
148+
typeof pluginItem.options === 'object' && extend(options, pluginItem.options);
149+
} else {
150+
error('插件配置有误,请检查 ykit.js');
151+
process.exit(1);
152+
}
153+
142154
if(pluginName.indexOf(ykitConfigStartWith) === -1) {
143155
pluginName = ykitConfigStartWith + pluginName;
144156
}

0 commit comments

Comments
 (0)