From 7036723c2fabc80ae93184a21de866391127c3db Mon Sep 17 00:00:00 2001 From: Jordan Webb Date: Fri, 11 Nov 2022 14:43:20 -0600 Subject: [PATCH] Switch to running pyright with `npm exec` (#34) * Switch to running pyright with `npm exec` As suggested by @rnovacek in https://github.com/jordemort/action-pyright/issues/33 * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Disambiguate argument parsing Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- script.sh | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/script.sh b/script.sh index 110dae4..871c079 100755 --- a/script.sh +++ b/script.sh @@ -3,6 +3,7 @@ set -euo pipefail BASE_PATH="$(cd "$(dirname "$0")" && pwd)" +INPUT_PYRIGHT_VERSION=${INPUT_PYRIGHT_VERSION:-latest} cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1 @@ -14,14 +15,6 @@ echo '::group::🐶 Installing reviewdog ... https://github.com/reviewdog/review curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1 echo '::endgroup::' -echo '::group::🐍 Installing pyright ...' -if [ -z "${INPUT_PYRIGHT_VERSION:-}" ]; then - npm install pyright -else - npm install "pyright@${INPUT_PYRIGHT_VERSION}" -fi -echo '::endgroup::' - PYRIGHT_ARGS=(--outputjson) if [ -n "${INPUT_PYTHON_PLATFORM:-}" ]; then @@ -64,9 +57,9 @@ trap cleanup EXIT set -x # shellcheck disable=SC2086 -"$(npm bin)/pyright" "${PYRIGHT_ARGS[@]}" ${INPUT_PYRIGHT_FLAGS:-} > "$RDTMP/pyright.json" || true +npm exec --yes -- "pyright@${INPUT_PYRIGHT_VERSION}" "${PYRIGHT_ARGS[@]}" ${INPUT_PYRIGHT_FLAGS:-} >"$RDTMP/pyright.json" || true -python3 "${BASE_PATH}/pyright_to_rdjson/pyright_to_rdjson.py" < "$RDTMP/pyright.json" > "$RDTMP/rdjson.json" +python3 "${BASE_PATH}/pyright_to_rdjson/pyright_to_rdjson.py" <"$RDTMP/pyright.json" >"$RDTMP/rdjson.json" set +e # shellcheck disable=SC2086