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:
parent
807bafe417
commit
df8eabb3ef
@ -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.
|
||||
|
26
examples/cross-platform.just
Normal file
26
examples/cross-platform.just
Normal 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 }}
|
Loading…
Reference in New Issue
Block a user