From 11241905fe28cfceee247d7da49d70f3c87132d4 Mon Sep 17 00:00:00 2001 From: tomeichlersmith Date: Tue, 5 Nov 2024 13:08:44 -0600 Subject: [PATCH] use denv v1.1.0's quiet no-overwrite init flags this simplifies just init for newer denv and avoids a confusing error message that is usually just passed by --- justfile | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/justfile b/justfile index 305d4b760..5e4e8ce5c 100644 --- a/justfile +++ b/justfile @@ -102,18 +102,28 @@ debug config_py *ARGS: # initialize a containerized development environment init: #!/usr/bin/env sh - # while setting the denv_workspace is helpful for other - # commands that can assume the denv is already initialized, - # we need to unset this environment variable to make sure - # the test is done appropriately. - # just makes sure this recipe runs from the directory of - # the justfile so we know we are in the correct location. - unset denv_workspace - if denv check --workspace --quiet; then - echo "\033[32mWorkspace already initialized.\033[0m" - denv config print + denv_major=$(denv version | sed 's/denv v//' | cut -f 1 -d.) + denv_minor=$(denv version | set 's/denv v//' | cut -f 2 -d.) + if [ "${denv_major}" -lt 1 ] || [ "${denv_minor}" -lt "1" ]; then + # denv v1.0.X or earlier, manually check for workspace + # which may print a confusing error from denv when no workspace is found + unset denv_workspace + # while setting the denv_workspace is helpful for other + # commands that can assume the denv is already initialized, + # we need to unset this environment variable to make sure + # the test is done appropriately. + # just makes sure this recipe runs from the directory of + # the justfile so we know we are in the correct location. + if denv check --workspace --quiet; then + echo "\033[32mWorkspace already initialized.\033[0m" + denv config print + else + denv init --clean-env --name ldmx ldmx/dev:latest ${LDMX_BASE} + fi else - denv init --clean-env --name ldmx ldmx/dev:latest ${LDMX_BASE} + # denv v1.1.0 and later has updated denv init to allow us + # to avoid overwriting quietly + denv init --clean-env --no-over --no-mkdir --name ldmx ldmx/dev:latest ${LDMX_BASE} fi # check that the necessary programs for running ldmx-sw are present