Created
November 25, 2022 15:35
-
-
Save dereckmezquita/857ecb79c9623a898a962e859b544f6f to your computer and use it in GitHub Desktop.
Replaces RStudio's buttons for building and installing an R package during development.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# if $1 does not match either check or install | |
if [[ $1 != "check" ]] && [[ $1 != "install" ]] && [[ $1 != "check-install" ]]; then | |
echo "Usage: package-management.sh [check|install|check-install]" | |
fi | |
if [[ $1 == "check" ]]; then | |
Rscript -e "devtools::check()" | |
fi | |
if [[ $1 == "install" ]]; then | |
# get name of current directory | |
PROJECT_DIR=$(pwd) | |
PKGNAME=$(basename $(pwd)) | |
cd .. | |
R CMD build $PKGNAME | |
R CMD INSTALL --no-multiarch --with-keep.source $PKGNAME | |
cd $PROJECT_DIR | |
fi | |
if [[ $1 == "check-install" ]]; then | |
Rscript -e "devtools::check()" | |
# get name of current directory | |
PROJECT_DIR=$(pwd) | |
PKGNAME=$(basename $(pwd)) | |
cd .. | |
R CMD build $PKGNAME | |
R CMD INSTALL --no-multiarch --with-keep.source $PKGNAME | |
cd $PROJECT_DIR | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment