Skip to content

Commit

Permalink
Merge pull request #124 from opensafely/Jongmassey/pass-workspace-dir…
Browse files Browse the repository at this point in the history
…-to-postcreate

Pass workspace path into postCreate script
  • Loading branch information
Jongmassey authored May 10, 2024
2 parents 7788bb3 + 78d7848 commit 92d8289
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dockerDashComposeVersion": "v2"
}
},
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh",
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh ${containerWorkspaceFolder}",
"postAttachCommand": {
"rstudio-start": "sudo rstudio-server start"
},
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -euo pipefail
pip3 install --user -r .devcontainer/requirements.in

#set R working directory
! grep -q `pwd` $R_HOME/etc/Rprofile.site && sudo tee -a $R_HOME/etc/Rprofile.site <<< "setwd(\"`pwd`\")"
! grep -q "$1" $R_HOME/etc/Rprofile.site && sudo tee -a $R_HOME/etc/Rprofile.site <<< "setwd(\"$1\")"
#set RStudio working directory
! grep -q `pwd` ~/.config/rstudio/rstudio-prefs.json && cat ~/.config/rstudio/rstudio-prefs.json | jq ". + {\"initial_working_directory\":\"`pwd`\"}" > ~/.config/rstudio/rstudio-prefs.json
! grep -q "$1" ~/.config/rstudio/rstudio-prefs.json && cat ~/.config/rstudio/rstudio-prefs.json | jq ". + {\"initial_working_directory\":\"$1\"}" > ~/.config/rstudio/rstudio-prefs.json
#download and extract latest ehrql source
wget https://github.com/opensafely-core/ehrql/archive/main.zip -P .devcontainer
Expand Down

0 comments on commit 92d8289

Please sign in to comment.