mirror of
https://github.com/orhun/git-cliff-action.git
synced 2026-03-22 07:25:43 +08:00
fix(args): allow setting the output via --output argument (#53)
This commit is contained in:
22
run.sh
22
run.sh
@@ -21,8 +21,26 @@ chown -R "$(id -u)" .
|
||||
OUTPUT=${OUTPUT:="git-cliff/CHANGELOG.md"}
|
||||
mkdir -p "$(dirname $OUTPUT)"
|
||||
|
||||
# Separate arguments before passing them to git-cliff command
|
||||
args=$(echo "$@" | xargs)
|
||||
args=()
|
||||
take_next=
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
-o | --output)
|
||||
take_next=1 # next argument is the output file
|
||||
;;
|
||||
-o=* | --output=*)
|
||||
OUTPUT="${arg#*=}" # consume the output file directly
|
||||
;;
|
||||
*)
|
||||
if [ -n "$take_next" ]; then
|
||||
OUTPUT="$arg"
|
||||
take_next=
|
||||
else
|
||||
args+=("$arg") # keep only non-output args
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Execute git-cliff
|
||||
GIT_CLIFF_OUTPUT="$OUTPUT" "$GIT_CLIFF_PATH" $args
|
||||
|
||||
Reference in New Issue
Block a user