Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple path_to_rmd guessed incorrectly in Dockerfile & .travis.yml when paper_files/ dir exists in paper/ #99

Closed
annakrystalli opened this issue Sep 11, 2019 · 1 comment

Comments

@annakrystalli
Copy link
Contributor

Please wait for some discussion of your report before making a Pull Request.

Describe the bug

If one has rendered the paper manually and a paper_files/ folder has been created within paper/, this confuses the guessing of the path to paper.Rmd erroneous paths to be added to the populated Dockerfile & .travis.yml templates .

To Reproduce

dir.create("analysis/paper/paper_files", recursive = T)
dir_list   <- list.dirs()
paper_dir  <- dir_list[grep(pattern = "/paper", dir_list)]
paper_dir
#> [1] "./analysis/paper"             "./analysis/paper/paper_files"
rmd_path   <- regmatches(paper_dir, regexpr("analysis|vignettes|inst", paper_dir))
rmd_path
#> [1] "analysis" "analysis"
rmd_path <-  file.path(rmd_path, "paper/paper.Rmd")
rmd_path
#> [1] "analysis/paper/paper.Rmd" "analysis/paper/paper.Rmd"

Created on 2019-09-11 by the reprex package (v0.3.0)

In practice, this results in the Dockerfile resulting from use_dockerfile() containing this incorrect markdown::render() command:

  && R -e "rmarkdown::render('/rrcompendiumRSE19/analysis/paper/paper.Rmd,analysis/paper/paper.Rm')"

Same problem with the .travis.yml file from rrtools::use_travis()

Expected behavior

I think this can be fixed by adding a $ to the end of the pattern in grep(). eg:

dir.create("analysis/paper/paper_files", recursive = T)
dir_list   <- list.dirs()
paper_dir  <- dir_list[grep(pattern = "/paper$", dir_list)]
paper_dir
#> [1] "./analysis/paper"
rmd_path   <- regmatches(paper_dir, regexpr("analysis|vignettes|inst", paper_dir))
rmd_path
#> [1] "analysis"
rmd_path <-  file.path(rmd_path, "paper/paper.Rmd")
rmd_path
#> [1] "analysis/paper/paper.Rmd"

returns only a single file path

Created on 2019-09-11 by the reprex package (v0.3.0)

@benmarwick
Copy link
Owner

Thanks! I think I can follow what you're describing here, I'll take a closer look!

annakrystalli added a commit to annakrystalli/rrtools that referenced this issue Sep 16, 2019
Issue benmarwick#99 was a problem in both `use_dockerfile()` and `use_travis()`.  48ac6a1 only addresses the problem in `use_dockerfile()`. This fixes `use_travis()`.
benmarwick added a commit that referenced this issue Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants