Comparing version 1.4.0 to 1.5.0
1.5.0 / 2017-01-17 | ||
================== | ||
* feat: plugin support optionalDependencies (#40) | ||
1.4.0 / 2017-01-12 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -184,3 +184,4 @@ 'use strict'; | ||
enable: plugin, | ||
dep: [], | ||
dependencies: [], | ||
optionalDependencies: [], | ||
env: [], | ||
@@ -196,5 +197,7 @@ from: configPath, | ||
plugin.name = name; | ||
plugin.dep = plugin.dep || []; | ||
plugin.dependencies = plugin.dependencies || []; | ||
plugin.optionalDependencies = plugin.optionalDependencies || []; | ||
plugin.env = plugin.env || []; | ||
plugin.from = configPath; | ||
depCompatible(plugin); | ||
}, | ||
@@ -234,3 +237,6 @@ | ||
for (const key of [ 'dep', 'env' ]) { | ||
// dep compatible | ||
depCompatible(config); | ||
for (const key of [ 'dependencies', 'optionalDependencies', 'env' ]) { | ||
if (!plugin[key].length && Array.isArray(config[key])) { | ||
@@ -258,3 +264,3 @@ plugin[key] = config[key]; | ||
for (const name in allPlugins) { | ||
if (allPlugins[name].dep.indexOf(missName) >= 0) { | ||
if (allPlugins[name].dependencies.indexOf(missName) >= 0) { | ||
requires.push(name); | ||
@@ -274,3 +280,3 @@ } | ||
result.sequence.forEach(name => { | ||
for (const depName of allPlugins[name].dep) { | ||
for (const depName of allPlugins[name].dependencies) { | ||
if (!requireMap[depName]) { | ||
@@ -363,1 +369,8 @@ requireMap[depName] = []; | ||
}; | ||
function depCompatible(plugin) { | ||
if (plugin.dep && !(Array.isArray(plugin.dependencies) && plugin.dependencies.length)) { | ||
plugin.dependencies = plugin.dep; | ||
delete plugin.dep; | ||
} | ||
} |
'use strict'; | ||
function sequence(tasks, names, results, missing, recursive, nest) { | ||
function sequence(tasks, names, results, missing, recursive, nest, optional) { | ||
names.forEach(function(name) { | ||
@@ -10,2 +10,5 @@ if (results.indexOf(name) !== -1) { | ||
if (!node) { | ||
if (optional === true) { | ||
return; | ||
} | ||
missing.push(name); | ||
@@ -16,5 +19,10 @@ } else if (nest.indexOf(name) > -1) { | ||
nest.pop(name); | ||
} else if (node.dep.length) { | ||
} else if (node.dependencies.length || node.optionalDependencies.length) { | ||
nest.push(name); | ||
sequence(tasks, node.dep, results, missing, recursive, nest); // recurse | ||
if (node.dependencies.length) { | ||
sequence(tasks, node.dependencies, results, missing, recursive, nest); | ||
} | ||
if (node.optionalDependencies.length) { | ||
sequence(tasks, node.optionalDependencies, results, missing, recursive, nest, true); | ||
} | ||
nest.pop(name); | ||
@@ -21,0 +29,0 @@ } |
{ | ||
"name": "egg-core", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A core Pluggable framework based on koa", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
62300
1643