mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-25 15:41:02 -05:00
Better pswh module validation
This commit is contained in:
parent
da41dfe6fb
commit
87036c3987
1 changed files with 6 additions and 26 deletions
|
@ -210,36 +210,16 @@ function GetValidationInfo() {
|
||||||
#### Function ValidatePowershellModules ########################################
|
#### Function ValidatePowershellModules ########################################
|
||||||
function ValidatePowershellModules() {
|
function ValidatePowershellModules() {
|
||||||
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
|
VALIDATE_PSSA_MODULE=$(pwsh -c "(Get-Module -Name PSScriptAnalyzer -ListAvailable | Select-Object -First 1).Name" 2>&1)
|
||||||
# If module found, ensure Invoke-ScriptAnalyzer command is available
|
|
||||||
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]]; then
|
|
||||||
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
VALIDATE_PSSA_CMD=$(pwsh -c "(Get-Command Invoke-ScriptAnalyzer | Select-Object -First 1).Name" 2>&1)
|
||||||
else
|
# If module found, ensure Invoke-ScriptAnalyzer command is available
|
||||||
fatal "Failed to find module."
|
if [[ ${VALIDATE_PSSA_MODULE} == "PSScriptAnalyzer" ]] && [[ ${VALIDATE_PSSA_CMD} == "Invoke-ScriptAnalyzer" ]]; then
|
||||||
fi
|
|
||||||
|
|
||||||
#########################################
|
|
||||||
# validate we found the script analyzer #
|
|
||||||
#########################################
|
|
||||||
if [[ ${VALIDATE_PSSA_CMD} != "Invoke-ScriptAnalyzer" ]]; then
|
|
||||||
fatal "Failed to find module."
|
|
||||||
fi
|
|
||||||
|
|
||||||
#######################
|
|
||||||
# Load the error code #
|
|
||||||
#######################
|
|
||||||
ERROR_CODE=$?
|
|
||||||
|
|
||||||
##############################
|
|
||||||
# Check the shell for errors #
|
|
||||||
##############################
|
|
||||||
if [ ${ERROR_CODE} -ne 0 ]; then
|
|
||||||
# Failed
|
|
||||||
error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!"
|
|
||||||
fatal "[PSSA_MODULE ${VALIDATE_PSSA_MODULE}] [PSSA_CMD ${VALIDATE_PSSA_CMD}]"
|
|
||||||
else
|
|
||||||
# Success
|
# Success
|
||||||
debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system"
|
debug "Successfully found module ${F[W]}[${VALIDATE_PSSA_MODULE}]${F[B]} in system"
|
||||||
debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system"
|
debug "Successfully found command ${F[W]}[${VALIDATE_PSSA_CMD}]${F[B]} in system"
|
||||||
|
else
|
||||||
|
# Failed
|
||||||
|
error "Failed find module [PSScriptAnalyzer] for [${LINTER_NAME}] in system!"
|
||||||
|
fatal "[PSSA_MODULE: ${VALIDATE_PSSA_MODULE}] [PSSA_CMD: ${VALIDATE_PSSA_CMD}]"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
Loading…
Reference in a new issue