From df8aedf12d7586941fa7f465c9114fb2d370e8db Mon Sep 17 00:00:00 2001 From: mshibanami Date: Sat, 17 Oct 2015 23:16:33 +0900 Subject: [PATCH] Add --skip-existing option. --- bin/ndenv-install | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/ndenv-install b/bin/ndenv-install index 15e777d..a17e5b4 100755 --- a/bin/ndenv-install +++ b/bin/ndenv-install @@ -6,11 +6,12 @@ # ndenv install [-f|--force] [-k|--keep] [-v|--verbose] # ndenv install -l|--list # -# -l/--list List all available versions -# -f/--force Install even if the version appears to be installed already -# -k/--keep Keep source tree in $NDENV_BUILD_ROOT after installation -# (defaults to $NDENV_ROOT/sources) -# -v/--verbose Verbose mode: print compilation status to stdout +# -l/--list List all available versions +# -f/--force Install even if the version appears to be installed already +# -k/--keep Keep source tree in $NDENV_BUILD_ROOT after installation +# (defaults to $NDENV_ROOT/sources) +# -v/--verbose Verbose mode: print compilation status to stdout +# -s/--skip-existing Skip if the version appears to be installed already # # For detailed information on installing Node versions with # node-build, including a list of environment variables for adjusting @@ -64,6 +65,9 @@ for option in "${OPTIONS[@]}"; do "f" | "force" ) FORCE=true ;; + "s" | "skip-existing" ) + SKIP_EXISTING=true + ;; "k" | "keep" ) [ -n "${NDENV_BUILD_ROOT}" ] || NDENV_BUILD_ROOT="${NDENV_ROOT}/sources" ;; @@ -121,6 +125,10 @@ PREFIX="${NDENV_ROOT}/versions/${VERSION_NAME}" # If the installation prefix exists, prompt for confirmation unless # the --force option was specified. if [ -z "$FORCE" ] && [ -d "${PREFIX}/bin" ]; then + if [ "$SKIP_EXISTING" = true ] ; then + exit 1 + fi + echo "ndenv: $PREFIX already exists" >&2 read -p "continue with installation? (y/N) "