Skip to content

Commit

Permalink
chore: use safer justfile bash config
Browse files Browse the repository at this point in the history
  • Loading branch information
madwort committed Aug 3, 2023
1 parent 1f4707b commit ded3d04
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ clean:
# ensure valid virtualenv
virtualenv:
#!/usr/bin/env bash
set -euo pipefail
# allow users to specify python version in .env
PYTHON_VERSION=${PYTHON_VERSION:-python3.10}

Expand All @@ -35,6 +37,8 @@ virtualenv:

_compile src dst *args: virtualenv
#!/usr/bin/env bash
set -euo pipefail
# exit if src file is older than dst file (-nt = 'newer than', but we negate with || to avoid error exit code)
test "${FORCE:-}" = "true" -o {{ src }} -nt {{ dst }} || exit 0
{{ COMPILE }} --output-file={{ dst }} {{ src }} {{ args }}
Expand All @@ -55,7 +59,7 @@ requirements-dev *args: virtualenv
# ensure prod requirements installed and up to date
#prodenv: requirements-prod
# #!/usr/bin/env bash
# set -eu
# set -euo pipefail
# # exit if .txt file has not changed since we installed them (-nt == "newer than', but we negate with || to avoid error exit code)
# test requirements.prod.txt -nt $VIRTUAL_ENV/.prod || exit 0
#
Expand All @@ -69,7 +73,8 @@ requirements-dev *args: virtualenv
# ensure dev requirements installed and up to date
devenv: requirements-dev && install-precommit
#!/usr/bin/env bash
set -eu
set -euo pipefail
# exit if .txt file has not changed since we installed them (-nt == "newer than', but we negate with || to avoid error exit code)
test requirements.dev.txt -nt $VIRTUAL_ENV/.dev || exit 0

Expand All @@ -80,13 +85,17 @@ devenv: requirements-dev && install-precommit
# ensure precommit is installed
install-precommit:
#!/usr/bin/env bash
set -euo pipefail
BASE_DIR=$(git rev-parse --show-toplevel)
test -f $BASE_DIR/.git/hooks/pre-commit || $BIN/pre-commit install


# upgrade dev or prod dependencies (specify package to upgrade single package, all by default)
upgrade env package="": virtualenv
#!/usr/bin/env bash
set -euo pipefail
opts="--upgrade"
test -z "{{ package }}" || opts="--upgrade-package {{ package }}"
FORCE=true {{ just_executable() }} requirements-{{ env }} $opts
Expand Down

0 comments on commit ded3d04

Please sign in to comment.