Skip to content

Commit 5adef71

Browse files
authored
Merge pull request #938 from per1234/check-npm
Check/fix problems with npm configuration
2 parents 3d3e431 + 2506adc commit 5adef71

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

.github/workflows/check-npm-task.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,44 @@ jobs:
126126
--color \
127127
--exit-code \
128128
"${{ matrix.project.path }}/package-lock.json"
129+
130+
check-config:
131+
name: check-config (${{ matrix.project.path }})
132+
needs: run-determination
133+
if: needs.run-determination.outputs.result == 'true'
134+
runs-on: ubuntu-latest
135+
permissions:
136+
contents: read
137+
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
project:
142+
- path: .
143+
144+
steps:
145+
- name: Checkout repository
146+
uses: actions/checkout@v5
147+
148+
- name: Setup Node.js
149+
uses: actions/setup-node@v4
150+
with:
151+
node-version-file: "${{ matrix.project.path }}/package.json"
152+
153+
- name: Install Task
154+
uses: arduino/setup-task@v2
155+
with:
156+
repo-token: ${{ secrets.GITHUB_TOKEN }}
157+
version: 3.x
158+
159+
- name: Fix problems in npm configuration file
160+
run: |
161+
task npm:fix-config \
162+
PROJECT_PATH="${{ matrix.project.path }}"
163+
164+
- name: Check if fixes are needed in npm configuration file
165+
run: |
166+
git diff \
167+
--color \
168+
--exit-code \
169+
"${{ matrix.project.path }}/.npmrc"

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# See: https://docs.npmjs.com/cli/configuring-npm/npmrc
22

3-
engine-strict = true
3+
engine-strict=true

Taskfile.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ tasks:
142142
vars:
143143
GO_MODULE_PATH: ./ruledocsgen
144144
- task: markdown:fix
145+
- task: npm:fix-config
145146
- task: python:format
146147
- task: shell:format
147148
vars:
@@ -477,6 +478,19 @@ tasks:
477478
markdownlint-cli \
478479
"**/*.md"
479480
481+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
482+
npm:fix-config:
483+
desc: |
484+
Fix problems with the npm configuration file.
485+
Environment variable parameters:
486+
- PROJECT_PATH: Path of the npm-managed project (default: {{.DEFAULT_NPM_PROJECT_PATH}}).
487+
dir: "{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}"
488+
cmds:
489+
- |
490+
npm config \
491+
--location project \
492+
fix
493+
480494
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
481495
npm:install-deps:
482496
desc: |

0 commit comments

Comments
 (0)