forked from r-lib/usethis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
37 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ License: GPL-3 | |
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 5.0.1 | ||
Suggests: testthat |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# usethis 0.0.0.9000 | ||
|
||
* Removed old `add_build_ignore()` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,31 @@ | ||
#' Add a file to \code{.Rbuildignore} | ||
#' Add files to \code{.Rbuildignore} | ||
#' | ||
#' \code{.Rbuildignore} has a regular expression on each line, but it's | ||
#' usually easier to work with specific file names. By default, will (crudely) | ||
#' turn a filename into a regular expression that will only match that | ||
#' path. Repeated entries will be silently removed. | ||
#' usually easier to work with specific file names. By default, | ||
#' \code{use_build_ignore} will (crudely) turn a filename into a regular | ||
#' expression that will only match that path. Repeated entries will be | ||
#' silently removed. | ||
#' | ||
#' @param pkg package description, can be path or package name. See | ||
#' \code{\link{as.package}} for more information | ||
#' @param files Name of file. | ||
#' @param base_path Base path to package root. | ||
#' @param files Character vector of path naems. | ||
#' @param escape If \code{TRUE}, the default, will escape \code{.} to | ||
#' \code{\\.} and surround with \code{^} and \code{$}. | ||
#' @return Nothing, called for its side effect. | ||
#' @export | ||
#' @aliases add_build_ignore | ||
#' @family infrastructure | ||
#' @keywords internal | ||
use_build_ignore <- function(files, escape = TRUE, pkg = ".") { | ||
pkg <- as.package(pkg) | ||
|
||
use_build_ignore <- function(files, escape = TRUE, base_path = ".") { | ||
if (escape) { | ||
files <- paste0("^", gsub("\\.", "\\\\.", files), "$") | ||
files <- escape_path(files) | ||
} | ||
|
||
path <- file.path(pkg$path, ".Rbuildignore") | ||
path <- file.path(base_path, ".Rbuildignore") | ||
union_write(path, files) | ||
|
||
invisible(TRUE) | ||
} | ||
|
||
|
||
add_build_ignore <- function(pkg = ".", files, escape = TRUE) { | ||
use_build_ignore(files, escape = escape, pkg = pkg) | ||
escape_path <- function(x) { | ||
x <- gsub("\\.", "\\\\.", x) | ||
paste0("^", x, "$") | ||
} | ||
|
||
|
||
|
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library(testthat) | ||
library(usethis) | ||
|
||
test_check("usethis") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
context("use_build_ignore") | ||
|
||
test_that(". escaped around surround by anchors", { | ||
expect_equal(escape_path("."), "^\\.$") | ||
}) |