Skip to content

Commit 420283a

Browse files
authored
fix(platform): cross-platform Taskfile preconditions (#94)
1 parent 4b3aaff commit 420283a

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

Taskfile.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tasks:
3636
status:
3737
# Don't do any of this if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
3838
# https://yaml.org/spec/1.2.2/#691-node-tags
39-
- '! test -d .git'
39+
- '! git rev-parse --git-dir'
4040
cmds:
4141
- uv tool install pre-commit
4242
# Don't run this in pipelines
@@ -93,8 +93,8 @@ tasks:
9393
update:
9494
desc: Update the project dev and runtime dependencies
9595
cmds:
96-
# Upgrade uv via brew on macOS/Linux when running locally (not CI)
97-
- '{{if and (ne .GITHUB_ACTIONS "true") (ne OS "windows")}}brew upgrade uv{{end}}'
96+
# Upgrade uv when running locally (not CI); use brew on macOS/Linux, uv self update on Windows
97+
- '{{if ne .GITHUB_ACTIONS "true"}}{{if ne OS "windows"}}brew upgrade uv{{else}}uv self update{{end}}{{end}}'
9898
- uv tool upgrade --all
9999
- pre-commit autoupdate --freeze --jobs 4
100100
# Copy the newly updated config into the project template, excluding the exclude line
@@ -128,9 +128,9 @@ tasks:
128128
env:
129129
GH_TOKEN:
130130
sh: |
131-
if [[ -n "${GH_TOKEN:-}" ]]; then
131+
if [ -n "${GH_TOKEN:-}" ]; then
132132
echo "${GH_TOKEN}"
133-
elif command -v gh &> /dev/null && gh auth token &> /dev/null; then
133+
elif gh auth token > /dev/null 2>&1; then
134134
gh auth token
135135
fi
136136
cmds:

{{cookiecutter.project_name}}/Taskfile.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tasks:
3434
- pyproject.toml
3535
- uv.lock
3636
preconditions:
37-
- which uv
37+
- uv --version
3838
cmds:
3939
# Sync dependencies with uv
4040
- uv sync --frozen --all-extras
@@ -47,7 +47,7 @@ tasks:
4747
status:
4848
# Don't do any of this if you aren't in a git repository; quote to avoid yaml intrepretering the ! as a node tag
4949
# https://yaml.org/spec/1.2.2/#691-node-tags
50-
- '! test -d .git'
50+
- '! git rev-parse --git-dir'
5151
cmds:
5252
- uv tool install pre-commit
5353
# Don't run this in pipelines
@@ -173,8 +173,8 @@ tasks:
173173
update:
174174
desc: Update the project dev and runtime dependencies
175175
cmds:
176-
# Upgrade uv via brew on macOS/Linux when running locally (not CI)
177-
- '{{ '{{if and (ne .GITHUB_ACTIONS "true") (ne OS "windows")}}' }}brew upgrade uv{{ '{{end}}' }}'
176+
# Upgrade uv when running locally (not CI); use brew on macOS/Linux, uv self update on Windows
177+
- '{{ '{{if ne .GITHUB_ACTIONS "true"}}{{if ne OS "windows"}}' }}brew upgrade uv{{ '{{else}}' }}uv self update{{ '{{end}}{{end}}' }}'
178178
- uv tool upgrade --all
179179
- pre-commit autoupdate --freeze --jobs 4
180180
- uv lock --upgrade
@@ -205,9 +205,9 @@ tasks:
205205
env:
206206
GH_TOKEN:
207207
sh: |
208-
if [[ -n "${GH_TOKEN:-}" ]]; then
208+
if [ -n "${GH_TOKEN:-}" ]; then
209209
echo "${GH_TOKEN}"
210-
elif command -v gh &> /dev/null && gh auth token &> /dev/null; then
210+
elif gh auth token > /dev/null 2>&1; then
211211
gh auth token
212212
fi
213213
cmds:

0 commit comments

Comments
 (0)