mirror of
https://github.com/flynx/features.js.git
synced 2025-10-29 18:30:11 +00:00
better dependency loop detection...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
11f1c08456
commit
48bb6b2746
33
features.js
33
features.js
@ -553,6 +553,10 @@ var FeatureSetProto = {
|
|||||||
// complexity is far better...
|
// complexity is far better...
|
||||||
var max = l * l
|
var max = l * l
|
||||||
|
|
||||||
|
var moved = []
|
||||||
|
var chain = []
|
||||||
|
var chains = []
|
||||||
|
|
||||||
for(var i=0; i < lst.length; i++){
|
for(var i=0; i < lst.length; i++){
|
||||||
var k = lst[i]
|
var k = lst[i]
|
||||||
var depends = (that[k].depends || []).slice()
|
var depends = (that[k].depends || []).slice()
|
||||||
@ -584,8 +588,31 @@ var FeatureSetProto = {
|
|||||||
|
|
||||||
// move the dependencies after k...
|
// move the dependencies after k...
|
||||||
// NOTE: this will keep the order within the dependencies...
|
// NOTE: this will keep the order within the dependencies...
|
||||||
move.length > 0
|
if(move.length > 0){
|
||||||
&& lst.splice.apply(lst, [i+1, 0].concat(move))
|
lst.splice.apply(lst, [i+1, 0].concat(move))
|
||||||
|
|
||||||
|
// unseen feature -> new chain...
|
||||||
|
if(moved.indexOf(k) < 0){
|
||||||
|
chain = []
|
||||||
|
}
|
||||||
|
|
||||||
|
moved.push(k)
|
||||||
|
|
||||||
|
// chain completed -> check and store...
|
||||||
|
if(chain.indexOf(k) >= 0){
|
||||||
|
var c = JSON.stringify(chain)
|
||||||
|
// repeating chain -> loop detected...
|
||||||
|
if(chains.indexOf(c) >= 0){
|
||||||
|
console.error('Feature cyclic dependency:', chain)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
chains.push(c)
|
||||||
|
|
||||||
|
// add item to chain...
|
||||||
|
} else {
|
||||||
|
chain.push(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check for cyclic dependencies...
|
// check for cyclic dependencies...
|
||||||
// XXX loop signs:
|
// XXX loop signs:
|
||||||
@ -597,7 +624,7 @@ var FeatureSetProto = {
|
|||||||
// - ...
|
// - ...
|
||||||
if(lst.length >= max){
|
if(lst.length >= max){
|
||||||
// XXX get the actual cycle...
|
// XXX get the actual cycle...
|
||||||
console.error('Feature cyclic dependency...')
|
console.error('Feature cyclic dependency:', chain)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-features",
|
"name": "ig-features",
|
||||||
"version": "2.2.4",
|
"version": "2.2.5",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "features.js",
|
"main": "features.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user