Skip to content

Commit bffab9f

Browse files
committed
fix: resolve python or python3 in setup script
1 parent 6356389 commit bffab9f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎setup.ps1‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ if (-not (Test-Command 'git')) {
1818
exit 1
1919
}
2020

21-
if (-not (Test-Command 'python')) {
21+
$Python = if (Test-Command 'python') { 'python' } elseif (Test-Command 'python3') { 'python3' } else { $null }
22+
if (-not $Python) {
2223
Write-Error 'Python not found in PATH. Install Python 3 (python.org) with "Add to PATH" and retry.'
2324
exit 1
2425
}
@@ -30,14 +31,14 @@ if ($LASTEXITCODE -ne 0) {
3031
exit 1
3132
}
3233

33-
python -m pre_commit --version > $null 2>&1
34+
& $Python -m pre_commit --version > $null 2>&1
3435
if ($LASTEXITCODE -ne 0) {
3536
Write-Host 'pre-commit not found, installing via pip...'
36-
python -m pip install --user pre-commit
37+
& $Python -m pip install --user pre-commit
3738
}
3839

3940
# Use `python -m` so it works even if pip --user Scripts dir is not on PATH.
40-
python -m pre_commit install
41+
& $Python -m pre_commit install
4142
Write-Host ''
4243
Write-Host 'Done. Hooks will run on every commit.'
4344
Write-Host 'To check everything right now: pre-commit run --all-files'

0 commit comments

Comments
 (0)