Skip to content

Commit 973c67c

Browse files
committed
feat: added new wrapper script pre-commit-run.sh to support array parameters of PSScriptAnalyzer-wrapper.ps1
1 parent e405ca8 commit 973c67c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

pre-commit-run.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
SOURCE=${BASH_SOURCE[0]}
4+
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
5+
DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
6+
SOURCE=$(readlink "$SOURCE")
7+
[[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
8+
done
9+
SCRIPT_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
10+
11+
PWSH_PATH="${PRE_COMMIT_PWSH_PATH:-pwsh}"
12+
13+
if ! command -v "$PWSH_PATH" >/dev/null 2>&1; then
14+
echo "[ERR] $PWSH_PATH (PowerShell) executable not found"
15+
exit 1
16+
fi
17+
18+
"$PWSH_PATH" -Command "${SCRIPT_DIR}/PSScriptAnalyzer-wrapper.ps1" "$@"

0 commit comments

Comments
 (0)