Skip to content

Commit

Permalink
Merge pull request #81 from nrarnt/master
Browse files Browse the repository at this point in the history
Added option to use renv if renvlock is present
  • Loading branch information
gaborcsardi authored Feb 26, 2024
2 parents 3ecf894 + b72a8b2 commit 32cfbaf
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions installr
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
set -e

usage() {
echo "Usage: $0 [ -c | -d ] [ -a pkgs ] [ -t pkgs ] [ -r ] [ -p ] REMOTES ..."
echo "Usage: $0 [ -c | -d ] [ -e ] [ -a pkgs ] [ -t pkgs ] [ -r ] [ -p ] REMOTES ..."
echo
echo "Options:"
echo " -c install C and C++ compilers and keep them"
echo " -d install C and C++ compilers, temporarily"
echo " -a install Alpine packages and keep them"
echo " -t install Alpine packages, temporarily"
echo " -p do not remove pak after the installation (ignored if -r is given)".
echo " -e use renv to restore the renv.lock file if present."
echo
echo "REMOTES may be:"
echo " * package names from CRAN/Bioconductor, e.g. ggplot2"
Expand All @@ -27,14 +28,16 @@ error() {

unset KEEP_PAK

while getopts 'pcda:t:?h' o

while getopts 'pecda:t:?h' o
do
case $o in
a) APKG_FIN=$OPTARG ; shift ;;
t) APKG_TMP=$OPTARG ; shift ;;
c) APKG_COMPILERS=true ;;
d) APKG_COMPILERS_TMP=true ;;
p) KEEP_PAK=true ;;
e) USE_RENV=true ;;
h|?) usage ;;
esac
shift
Expand Down Expand Up @@ -84,6 +87,19 @@ if [[ -z "$KEEP_PAK" ]]; then
Rscript -e 'remove.packages("pak")'
fi


echo --------------------------------------
echo "Activating and Restoring renv.lock file if needed."
if [[ "$USE_RENV" == true ]]; then
if [[ -f "./renv.lock" ]]; then
Rscript -e 'renv::consent(provided = TRUE)'
Rscript -e 'renv::restore()'
else
echo "renv.lock file is not present in the current directory."
fi
fi
rm -rf /tmp/Rtmp*

echo
echo --------------------------------------
[[ -n "$APKG_TMP" ]] && echo Removing "$APKG_TMP"
Expand Down

0 comments on commit 32cfbaf

Please sign in to comment.