From 507afd74a788f0d289c08c5aa0729e08a49fb681 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Fri, 19 Jun 2020 20:51:12 +0000 Subject: [PATCH] Move to separate pwshlint script for better handling --- lib/linter.sh | 9 ++------- lib/pwshlint.ps1 | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 lib/pwshlint.ps1 diff --git a/lib/linter.sh b/lib/linter.sh index 81e19a20..ca8c5837 100755 --- a/lib/linter.sh +++ b/lib/linter.sh @@ -1653,12 +1653,7 @@ LintCodebase() ################################ # Lint the file with the rules # ################################ - #Special Handling for Powershell Required - if [ $FILE_TYPE -eq 'POWERSHELL' ];then - - else - LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) - fi + LINT_CMD=$(cd "$GITHUB_WORKSPACE" || exit; $LINTER_COMMAND "$FILE" 2>&1) ####################### # Load the error code # @@ -2285,7 +2280,7 @@ if [ "$VALIDATE_POWERSHELL" == "true" ]; then # Lint the powershell files # ############################# # LintCodebase "FILE_TYPE" "LINTER_NAME" "LINTER_CMD" "FILE_TYPES_REGEX" "FILE_ARRAY" - LintCodebase "POWERSHELL" "pwsh" "pwsh -c 'Invoke-ScriptAnalyzer -Settings $POWERSHELL_LINTER_RULES -Path '" ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" + LintCodebase "POWERSHELL" "/action/lib/pwshlint.ps1" "/action/lib/pwshlint.ps1 $POWERSHELL_LINTER_RULES " ".*\.\(ps[md]\?1\)\$" "${FILE_ARRAY_POWERSHELL[@]}" fi ########## diff --git a/lib/pwshlint.ps1 b/lib/pwshlint.ps1 new file mode 100644 index 00000000..8045282e --- /dev/null +++ b/lib/pwshlint.ps1 @@ -0,0 +1,6 @@ +#!/usr/bin/pwsh +param( + [String]$SettingsPath, + [String]$FileToAnalyze +) +Invoke-ScriptAnalyzer -Settings $SettingsPath -Path $FileToAnalyze \ No newline at end of file