Skip to content

Commit 2affc92

Browse files
committed
Make default npm project path configurable via taskfile variable
A repository might contain multiple npm-managed projects. For this reason, the appropriate npm-managed tasks have a parameter environment variable that allows it to be configured for an arbitrary path, with the "Check npm" workflow having a job matrix of paths to pass. Generally, even if there are multiple npm-managed projects, there will be one primary project that is most often the target of contributor operation. Since it would be inconvenient for the contributor to pass the environment variable path every time they want to run a task for that primary project, the tasks are configured to have a default path which is used if the variable is not defined by the user. Since the primary npm-managed project would typically be in the root of the repository, the default value is set to the root. In the case where the primary npm-managed project is not in the root of the repository, the template installer will need to adjust this. Previously the default was hard coded in each individual task. The template will be made easier to install by defining the default in a single place via a friendly taskfile variable, following the convention already established by the templates for Go-based projects.
1 parent 4949c82 commit 2affc92

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Taskfile.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ includes:
55
dist: ./DistTasks.yml
66

77
vars:
8+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
9+
# Path of the project's primary npm-managed project:
10+
DEFAULT_NPM_PROJECT_PATH: .
811
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/release-go-task/Taskfile.yml
912
PROJECT_NAME: "arduino-lint"
1013
DIST_DIR: "dist"
@@ -155,6 +158,8 @@ tasks:
155158
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
156159
deps:
157160
- task: npm:install-deps
161+
vars:
162+
PROJECT_PATH: .
158163
cmds:
159164
- |
160165
wget \
@@ -248,6 +253,8 @@ tasks:
248253
desc: Format all supported files with Prettier
249254
deps:
250255
- task: npm:install-deps
256+
vars:
257+
PROJECT_PATH: .
251258
cmds:
252259
- |
253260
npx \
@@ -412,6 +419,8 @@ tasks:
412419
deps:
413420
- task: docs:generate
414421
- task: npm:install-deps
422+
vars:
423+
PROJECT_PATH: .
415424
cmds:
416425
- |
417426
npx \
@@ -423,6 +432,8 @@ tasks:
423432
desc: Automatically correct linting violations in Markdown files where possible
424433
deps:
425434
- task: npm:install-deps
435+
vars:
436+
PROJECT_PATH: .
426437
cmds:
427438
- |
428439
npx \
@@ -435,6 +446,8 @@ tasks:
435446
desc: Check for problems in Markdown files
436447
deps:
437448
- task: npm:install-deps
449+
vars:
450+
PROJECT_PATH: .
438451
cmds:
439452
- |
440453
npx \
@@ -447,7 +460,7 @@ tasks:
447460
npm:install-deps:
448461
desc: Install dependencies managed by npm
449462
dir: |
450-
"{{default "./" .PROJECT_PATH}}"
463+
"{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}"
451464
cmds:
452465
- npm install
453466

@@ -498,7 +511,7 @@ tasks:
498511
STYLELINTRC_SCHEMA_PATH:
499512
sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json"
500513
INSTANCE_PATH: >-
501-
{{default "." .PROJECT_PATH}}/package.json
514+
{{default .DEFAULT_NPM_PROJECT_PATH .PROJECT_PATH}}/package.json
502515
PROJECT_FOLDER:
503516
sh: pwd
504517
WORKING_FOLDER:

0 commit comments

Comments
 (0)