From 20d06c5ef09ce6061c8637b93ebb2e8c37f3779d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Wed, 5 Feb 2025 21:24:56 +0900 Subject: [PATCH] Fix jq handling on Windows Fix regression introduced in unreleased 400052b460dab85e92ce8e701398ef3b58578adb. --- main.sh | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/main.sh b/main.sh index b0cd3295..f56e1849 100755 --- a/main.sh +++ b/main.sh @@ -604,7 +604,9 @@ case "${host_os}" in if ! type -P curl >/dev/null; then warn "install-action requires at least curl on Windows" fi - if type -P jq >/dev/null; then + if [[ -f "${install_action_dir}/jq/bin/jq.exe" ]]; then + jq() { "${install_action_dir}/jq/bin/jq.exe" -b "$@"; } + elif type -P jq >/dev/null; then # https://github.com/jqlang/jq/issues/1854 _tmp=$(jq -r .a <<<'{}') if [[ "${_tmp}" != "null" ]]; then @@ -614,19 +616,19 @@ case "${host_os}" in else jq() { command jq "$@" | tr -d '\r'; } fi - else - printf '::group::Install packages required for installation (jq)\n' - mkdir -p -- "${install_action_dir}/jq/bin" - url='https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-amd64.exe' - checksum='7451fbbf37feffb9bf262bd97c54f0da558c63f0748e64152dd87b0a07b6d6ab' - ( - cd -- "${install_action_dir}/jq/bin" - download_and_checksum "${url}" "${checksum}" - mv -- tmp jq.exe - ) - printf '::endgroup::\n' - jq() { "${install_action_dir}/jq/bin/jq.exe" -b "$@"; } fi + else + printf '::group::Install packages required for installation (jq)\n' + mkdir -p -- "${install_action_dir}/jq/bin" + url='https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-amd64.exe' + checksum='7451fbbf37feffb9bf262bd97c54f0da558c63f0748e64152dd87b0a07b6d6ab' + ( + cd -- "${install_action_dir}/jq/bin" + download_and_checksum "${url}" "${checksum}" + mv -- tmp jq.exe + ) + printf '::endgroup::\n' + jq() { "${install_action_dir}/jq/bin/jq.exe" -b "$@"; } fi ;; *) bail "unsupported host OS '${host_os}'" ;;