Skip to content

Commit

Permalink
add autodeps validation and methods to config interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Mar 16, 2024
1 parent c45fbed commit 3d388a9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/nocap/src/classes/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ export default class Base {
ensure_check_dependencies(){
if(!this.checksRequested.includes('open')){
this.checksRequested.unshift('open')
if(!this.checksIgnoreOutput.includes('open'))
if(!this.checksIgnoreOutput.includes('open') && this.config.is('autoDepsIgnoredInResult', true))
this.checksIgnoreOutput.push('open')
}
if(this.checksRequested.includes('geo') && !this.checksRequested.includes('dns')){
this.checksRequested.unshift('dns')
if(!this.checksIgnoreOutput.includes('dns'))
if(!this.checksIgnoreOutput.includes('dns') && this.config.is('autoDepsIgnoredInResult', true))
this.checksIgnoreOutput.push('dns')
}
}
Expand Down
31 changes: 29 additions & 2 deletions packages/nocap/src/interfaces/ConfigInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ export const ConfigDefaults = {
dns: {},
ssl: {}
},
autoDepsIgnoredInResult: true,
removeFromResult: [],
rejectOnConnectFailure: false,
failAllChecksOnConnectFailure: true
failAllChecksOnConnectFailure: true,
rejectOnConnectFailure: false
}

/**
Expand All @@ -46,5 +47,31 @@ export class ConfigInterface extends Validator {
set(key, value){
this._set(key, value)
}

eq(key, value){
return this._get(key) === value
}

gt(key, value){
try {
return this._get(key) > value
}
catch(e){
console.warn(`the value of "key" (arg 1) and the value (arg 2) must both be numbers (int, float)`)
}
}

lt(key, value){
try {
return this._get(key) < value
}
catch(e){
console.warn(`the value of "key" (arg 1) and the value (arg 2) must both be numbers (int, float)`)
}
}

is(key, value){
return this.eq(key, value)
}

}

0 comments on commit 3d388a9

Please sign in to comment.