Comparing version 0.6.0 to 1.0.0
1.0.0 / 2016-11-04 | ||
================== | ||
* feat: warn when redefine plugin (#28) | ||
* refactor: assert eggPath should be string | ||
0.6.0 / 2016-10-28 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -163,3 +163,3 @@ 'use strict'; | ||
const eggPath = proto[Symbol.for('egg#eggPath')]; | ||
// 使用 fs.realpathSync 来找到最终路径 | ||
assert(eggPath && typeof eggPath === 'string', 'Symbol.for(\'egg#eggPath\') should be string'); | ||
const realpath = fs.realpathSync(eggPath); | ||
@@ -166,0 +166,0 @@ if (eggPaths.indexOf(realpath) === -1) { |
@@ -90,5 +90,5 @@ 'use strict'; | ||
this.allPlugins = {}; | ||
extendPlugins(this.allPlugins, eggPlugins); | ||
extendPlugins(this.allPlugins, appPlugins); | ||
extendPlugins(this.allPlugins, customPlugins); | ||
this._extendPlugins(this.allPlugins, eggPlugins); | ||
this._extendPlugins(this.allPlugins, appPlugins); | ||
this._extendPlugins(this.allPlugins, customPlugins); | ||
@@ -171,3 +171,3 @@ const enabledPluginNames = []; // enabled plugins that configured explicitly | ||
extendPlugins(plugins, config); | ||
this._extendPlugins(plugins, config); | ||
} | ||
@@ -329,27 +329,32 @@ | ||
}; | ||
function extendPlugins(target, plugins) { | ||
if (!plugins) { | ||
return; | ||
} | ||
for (const name in plugins) { | ||
const plugin = plugins[name]; | ||
if (!target[name]) { | ||
target[name] = {}; | ||
_extendPlugins(target, plugins) { | ||
if (!plugins) { | ||
return; | ||
} | ||
if (plugin.path || plugin.package) { | ||
delete target[name].path; | ||
delete target[name].package; | ||
} | ||
for (const prop in plugin) { | ||
if (plugin[prop] === undefined) { | ||
continue; | ||
for (const name in plugins) { | ||
const plugin = plugins[name]; | ||
let targetPlugin = target[name]; | ||
if (!targetPlugin) { | ||
targetPlugin = target[name] = {}; | ||
} | ||
if (target[name][prop] && Array.isArray(plugin[prop]) && !plugin[prop].length) { | ||
continue; | ||
if ((targetPlugin.path || targetPlugin.package) && (plugin.path || plugin.package)) { | ||
this.options.logger.warn('plugin %s has been defined that is %j, but you define again in %s', | ||
name, targetPlugin, plugin.from); | ||
} | ||
target[name][prop] = plugin[prop]; | ||
if (plugin.path || plugin.package) { | ||
delete targetPlugin.path; | ||
delete targetPlugin.package; | ||
} | ||
for (const prop in plugin) { | ||
if (plugin[prop] === undefined) { | ||
continue; | ||
} | ||
if (targetPlugin[prop] && Array.isArray(plugin[prop]) && !plugin[prop].length) { | ||
continue; | ||
} | ||
targetPlugin[prop] = plugin[prop]; | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
}; |
{ | ||
"name": "egg-core", | ||
"version": "0.6.0", | ||
"version": "1.0.0", | ||
"description": "A core Pluggable framework based on koa", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,2 +30,8 @@ 'use strict'; | ||
}, | ||
zzz: { | ||
enable: true, | ||
path: path.join(__dirname, '../plugins/zzz'), | ||
}, | ||
}; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
session: false, | ||
zzz: false, | ||
}; |
@@ -66,2 +66,10 @@ 'use strict'; | ||
}); | ||
it('should assert eggPath type', () => { | ||
(function() { | ||
utils.createApp('eggpath', { | ||
Application: require(utils.getFilepath('framework-wrong-eggpath')), | ||
}); | ||
}).should.throw('Symbol.for(\'egg#eggPath\') should be string'); | ||
}); | ||
}); |
@@ -19,7 +19,7 @@ 'use strict'; | ||
const units = app.loader.getLoadUnits(); | ||
units.length.should.eql(10); | ||
units[8].type.should.eql('framework'); | ||
units[8].path.should.eql(utils.getFilepath('egg')); | ||
units[9].type.should.eql('app'); | ||
units[9].path.should.eql(utils.getFilepath('plugin')); | ||
units.length.should.eql(11); | ||
units[9].type.should.eql('framework'); | ||
units[9].path.should.eql(utils.getFilepath('egg')); | ||
units[10].type.should.eql('app'); | ||
units[10].path.should.eql(utils.getFilepath('plugin')); | ||
}); | ||
@@ -26,0 +26,0 @@ |
@@ -213,2 +213,3 @@ 'use strict'; | ||
'session', | ||
'zzz', | ||
// 'depd', | ||
@@ -409,2 +410,22 @@ // 'onerror', | ||
}); | ||
it('should warn when redefine plugin', () => { | ||
app = utils.createApp('load-plugin-config-override'); | ||
mm(app.console, 'warn', function(msg, name, targetPlugin, from) { | ||
msg.should.eql('plugin %s has been defined that is %j, but you define again in %s'); | ||
name.should.eql('zzz'); | ||
targetPlugin.should.eql({ | ||
enable: true, | ||
path: utils.getFilepath('egg/plugins/zzz'), | ||
name: 'zzz', | ||
dep: [], | ||
env: [], | ||
from: utils.getFilepath('egg/config/plugin.js'), | ||
}); | ||
from.should.eql(utils.getFilepath('load-plugin-config-override/config/plugin.js')); | ||
}); | ||
const loader = app.loader; | ||
loader.loadPlugin(); | ||
loader.allPlugins.zzz.path.should.eql(utils.getFilepath('load-plugin-config-override/plugins/zzz')); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
154065
329
4806
0
39