tweaks and fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-06-22 19:01:00 +03:00
parent 469932f01c
commit 5332667d9e
2 changed files with 23 additions and 20 deletions

View File

@ -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: // Feature attributes:
@ -240,16 +254,6 @@ Feature.prototype = FeatureProto
Feature.prototype.constructor = Feature 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 = { var FeatureSetProto = {
__feature__: Feature, __feature__: Feature,
@ -1331,31 +1335,30 @@ var FeatureSetProto = {
// if we have critical errors and set verbose... // if we have critical errors and set verbose...
var fatal = features.error var fatal = features.error
&& (features.error.loops.length > 0 || features.error.sort_loop_overflow) && (features.error.loops.length > 0 || features.error.sort_loop_overflow)
var verbose = this.__verbose__ || fatal
// report stuff... // report stuff...
if(verbose){ if(this.__verbose__){
var error = features.error
// report dependency loops... // report dependency loops...
features.error.loops.length > 0 error.loops.length > 0
&& loops && error.loops
.forEach(function(loop){ .forEach(function(loop){
console.warn('Feature dependency loops detected:\n\t' console.warn('Feature dependency loops detected:\n\t'
+ loop.join('\n\t\t-> ')) }) + loop.join('\n\t\t-> ')) })
// report conflicts... // report conflicts...
Object.keys(features.error.conflicts) Object.keys(error.conflicts)
.forEach(function(group){ .forEach(function(group){
console.error('Exclusive "'+ group +'" conflict at:', conflicts[group]) }) console.error('Exclusive "'+ group +'" conflict at:', error.conflicts[group]) })
// report loop limit... // report loop limit...
features.error.sort_loop_overflow error.sort_loop_overflow
&& console.error('Hit loop limit while sorting dependencies!') && console.error('Hit loop limit while sorting dependencies!')
} }
obj.features = features obj.features = features
// fatal error -- can't load... // fatal error -- can't load...
// XXX should we throw an error here???
if(fatal){ if(fatal){
throw FeatureLinearizationError(features) throw new FeatureLinearizationError(features)
} }
// do the setup... // do the setup...

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-features", "name": "ig-features",
"version": "3.1.0", "version": "3.1.1",
"description": "", "description": "",
"main": "features.js", "main": "features.js",
"scripts": { "scripts": {