From 6d058a525e151db1499ec4fd234f3463f0553567 Mon Sep 17 00:00:00 2001 From: Khsmty Date: Wed, 18 Oct 2023 16:19:58 +0900 Subject: [PATCH 1/3] add: package_manager option --- README.md | 5 +++++ action.yml | 4 ++++ script.sh | 9 +++++++++ 3 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 25a9e7b..43cf30f 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ Optional. Additional reviewdog flags textlint arguments (i.e. target dir:`doc/*`) +### `package_manager` + +Optional. Package manager used in the repository [npm,yarn,pnpm] +Default is `npm`. + ## Customizes `.textlintrc` put in your repo. diff --git a/action.yml b/action.yml index 4ebc1fa..df9e0dd 100644 --- a/action.yml +++ b/action.yml @@ -35,6 +35,9 @@ inputs: tool_name: description: 'Tool name to use for reviewdog reporter' default: 'textlint' + package_manager: + description: 'Package manager used in the repository' + default: 'npm' runs: using: 'composite' steps: @@ -52,6 +55,7 @@ runs: INPUT_REVIEWDOG_FLAGS: ${{ inputs.reviewdog_flags }} INPUT_TEXTLINT_FLAGS: ${{ inputs.textlint_flags }} INPUT_TOOL_NAME: ${{ inputs.tool_name }} + INPUT_PACKAGE_MANAGER: ${{ inputs.package_manager }} branding: icon: 'alert-octagon' color: 'blue' diff --git a/script.sh b/script.sh index 9237db5..221c9f6 100755 --- a/script.sh +++ b/script.sh @@ -14,6 +14,15 @@ echo '::endgroup::' echo '::group:: Installing textlint ... https://github.com/textlint/textlint' if [ -x "./node_modules/.bin/textlint" ]; then echo 'already installed' +elif INPUT_PACKAGE_MANAGER=npm; then + echo 'npm ci start' + npm ci +elif INPUT_PACKAGE_MANAGER=yarn; then + echo 'yarn install start' + yarn install +elif INPUT_PACKAGE_MANAGER=pnpm; then + echo 'pnpm install start' + pnpm install else echo 'npm ci start' npm ci From 91807bd487f2638e5a4db7e02595aed4312958c9 Mon Sep 17 00:00:00 2001 From: Khsmty Date: Wed, 18 Oct 2023 16:26:26 +0900 Subject: [PATCH 2/3] fix: option didn't work --- script.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script.sh b/script.sh index 221c9f6..c03e1a7 100755 --- a/script.sh +++ b/script.sh @@ -14,13 +14,13 @@ echo '::endgroup::' echo '::group:: Installing textlint ... https://github.com/textlint/textlint' if [ -x "./node_modules/.bin/textlint" ]; then echo 'already installed' -elif INPUT_PACKAGE_MANAGER=npm; then +elif [[ "${INPUT_PACKAGE_MANAGER}" == "npm" ]]; then echo 'npm ci start' npm ci -elif INPUT_PACKAGE_MANAGER=yarn; then +elif [[ "${INPUT_PACKAGE_MANAGER}" == "yarn" ]]; then echo 'yarn install start' yarn install -elif INPUT_PACKAGE_MANAGER=pnpm; then +elif [[ "${INPUT_PACKAGE_MANAGER}" == "pnpm" ]]; then echo 'pnpm install start' pnpm install else From 053e022faa1b1a52ecf0f08d0f8ab44cf19a6682 Mon Sep 17 00:00:00 2001 From: Khsmty Date: Wed, 18 Oct 2023 21:53:44 +0900 Subject: [PATCH 3/3] fix: show error with unsupported package manager --- script.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script.sh b/script.sh index c03e1a7..06ca5e6 100755 --- a/script.sh +++ b/script.sh @@ -24,8 +24,9 @@ elif [[ "${INPUT_PACKAGE_MANAGER}" == "pnpm" ]]; then echo 'pnpm install start' pnpm install else - echo 'npm ci start' - npm ci + echo 'The specified package manager is not supported.' + echo '::endgroup::' + exit 1 fi if [ -x "./node_modules/.bin/textlint" ]; then