mirror of
https://github.com/flynx/features.js.git
synced 2025-10-28 18:00:11 +00:00
tweaks and fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
469932f01c
commit
5332667d9e
41
features.js
41
features.js
@ -18,6 +18,20 @@ var args2array = function(a){ return [].slice.call(a) }
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
|
||||
var FeatureLinearizationError =
|
||||
module.FeatureLinearizationError =
|
||||
function(data){
|
||||
this.data = data
|
||||
this.message = `Failed to linearise from: ${data.input}`
|
||||
this.toString = function(){
|
||||
return this.message
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*********************************************************************/
|
||||
//
|
||||
// Feature attributes:
|
||||
@ -240,16 +254,6 @@ Feature.prototype = FeatureProto
|
||||
Feature.prototype.constructor = Feature
|
||||
|
||||
|
||||
var FeatureLinearizationError =
|
||||
module.FeatureLinearizationError = function(data){
|
||||
this.data = data
|
||||
this.message = `Failed to linearise from: ${data.input}`
|
||||
this.toString = function(){
|
||||
return this.message
|
||||
}
|
||||
}
|
||||
FeatureLinearizationError.prototype = Error
|
||||
|
||||
|
||||
var FeatureSetProto = {
|
||||
__feature__: Feature,
|
||||
@ -1331,31 +1335,30 @@ var FeatureSetProto = {
|
||||
// if we have critical errors and set verbose...
|
||||
var fatal = features.error
|
||||
&& (features.error.loops.length > 0 || features.error.sort_loop_overflow)
|
||||
var verbose = this.__verbose__ || fatal
|
||||
|
||||
// report stuff...
|
||||
if(verbose){
|
||||
if(this.__verbose__){
|
||||
var error = features.error
|
||||
// report dependency loops...
|
||||
features.error.loops.length > 0
|
||||
&& loops
|
||||
error.loops.length > 0
|
||||
&& error.loops
|
||||
.forEach(function(loop){
|
||||
console.warn('Feature dependency loops detected:\n\t'
|
||||
+ loop.join('\n\t\t-> ')) })
|
||||
// report conflicts...
|
||||
Object.keys(features.error.conflicts)
|
||||
Object.keys(error.conflicts)
|
||||
.forEach(function(group){
|
||||
console.error('Exclusive "'+ group +'" conflict at:', conflicts[group]) })
|
||||
console.error('Exclusive "'+ group +'" conflict at:', error.conflicts[group]) })
|
||||
// report loop limit...
|
||||
features.error.sort_loop_overflow
|
||||
error.sort_loop_overflow
|
||||
&& console.error('Hit loop limit while sorting dependencies!')
|
||||
}
|
||||
|
||||
obj.features = features
|
||||
|
||||
// fatal error -- can't load...
|
||||
// XXX should we throw an error here???
|
||||
if(fatal){
|
||||
throw FeatureLinearizationError(features)
|
||||
throw new FeatureLinearizationError(features)
|
||||
}
|
||||
|
||||
// do the setup...
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ig-features",
|
||||
"version": "3.1.0",
|
||||
"version": "3.1.1",
|
||||
"description": "",
|
||||
"main": "features.js",
|
||||
"scripts": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user