1
1
mirror of https://github.com/casey/just.git synced 2024-11-22 02:09:44 +03:00

Add cross-platform justfile example (#1152)

This commit is contained in:
Máté FARKAS 2022-04-12 06:39:55 +02:00 committed by GitHub
parent 807bafe417
commit df8eabb3ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View File

@ -893,6 +893,8 @@ $ just system-info
This is an x86_64 machine
```
The `os_family()` function can be used to create cross-platform `justfile`s that work on various operating systems. For an example, see [cross-platform.just](examples/cross-platform.just) file.
#### Environment Variables
- `env_var(key)` — Retrieves the environment variable with name `key`, aborting if it is not present.

View File

@ -0,0 +1,26 @@
# use with https://github.com/casey/just
#
# Example cross-platform Python project
#
python_dir := if os_family() == "windows" { "./.venv/Scripts" } else { "./.venv/bin" }
python := python_dir + if os_family() == "windows" { "/python.exe" } else { "/python3" }
system_python := if os_family() == "windows" { "py.exe -3.9" } else { "python3.9" }
# Set up development environment
bootstrap:
if test ! -e .venv; then {{ system_python }} -m venv .venv; fi
{{ python }} -m pip install --upgrade pip wheel pip-tools
{{ python_dir }}/pip-sync
# Upgrade Python dependencies
upgrade-deps: && bootstrap
{{ python_dir }}/pip-compile --upgrade
# Sample project script 1
script1:
{{ python }} script1.py
# Sample project script 2
script2 *ARGS:
{{ python }} script2.py {{ ARGS }}