Last active
          July 3, 2019 18:58 
        
      - 
      
 - 
        
Save kevinrue/6ecbc6d5070fb9346fd48dcbbb1d93ee to your computer and use it in GitHub Desktop.  
    A function to clone the content of an R package (perhaps other repositories too)
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | cloneRepo <- function(from, to) { | |
| repoFiles <- list.files(cloneSourceFolder, all.files = TRUE, include.dirs = TRUE) | |
| repoFiles <- setdiff(repoFiles, c(".", "..", ".git")) | |
| dir.create(to, recursive = TRUE) | |
| for (rootFile in repoFiles) { | |
| message(rootFile) | |
| file.copy( | |
| from = file.path(from, rootFile), | |
| to = file.path(to), | |
| recursive = TRUE, overwrite = TRUE) | |
| } | |
| } | |
| # example | |
| cloneSourceFolder <- "/Users/username/git/package" | |
| cloneDestinationFolder <- "/Users/username/git/package_clone" | |
| # usage | |
| cloneRepo(cloneSourceFolder, cloneDestinationFolder) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment