66# '
77# ' @param packageName \code{character} path to package source directory. Defaults to the current path when NULL.
88# ' @param vignettes \code{logical} specify whether to build vignettes. Default FALSE.
9- # ' @param log log level \code{INFO,WARN,DEBUG,FATAL}
109# ' @param deps \code{logical} should we pass data objects into subsequent scripts? Default TRUE
1110# ' @param install \code{logical} automatically install and load the package after building. Default FALSE
1211# ' @param ... additional arguments passed to \code{install.packages} when \code{install=TRUE}.
1514# ' @importFrom rprojroot is_r_package
1615# ' @importFrom rmarkdown pandoc_available
1716# ' @importFrom yaml read_yaml
18- # ' @importFrom futile.logger flog.logger flog.trace appender.file flog.debug flog.info flog.warn flog.error flog.fatal flog.appender flog.threshold INFO TRACE appender.console appender.tee
1917# ' @importFrom knitr knit spin
2018# ' @details Note that if \code{package_build} returns an error when rendering an \code{.Rmd}
2119# ' internally, but that same \code{.Rmd} can be run successfully manually using \code{rmarkdown::render},
4341# ' }
4442package_build <- function (packageName = NULL ,
4543 vignettes = FALSE ,
46- log = INFO ,
4744 deps = TRUE ,
4845 install = FALSE ,
4946 ... ) {
50- .multilog_setup(LOGFILE = NULL )
51- # flog.appender(appender.console())
5247 if (is.null(packageName )) {
5348 packageName <- " ."
5449 # use normalizePath
5550 package_path <- normalizePath(packageName , winslash = " /" )
5651 packageName <- basename(package_path )
5752 # Is this a package root?
5853 if (! is_r_package $ find_file() == package_path ) {
59- flog.fatal(paste0(package_path ,
60- " is not an R package root directory" ),
61- name = " console" )
62- stop(" exiting" , call. = FALSE )
54+ stop(paste(package_path , " is not an R package root directory" ))
6355 }
6456 } else {
6557 package_path <- normalizePath(packageName , winslash = " /" )
6658 if (! file.exists(package_path )) {
67- flog.fatal(paste0(" Non existent package " , packageName ), name = " console" )
68- stop(" exiting" , call. = FALSE )
59+ stop(paste(" Non existent package" , packageName ))
6960 }
7061 packageName <- basename(package_path )
7162 }
7263 # This should always be a proper name of a directory, either current or a
7364 # subdirectory
7465 tryCatch({is_r_package $ find_file(path = package_path )},
7566 error = function (cond ){
76- flog.fatal(paste0(
77- package_path ,
78- " is not a valid R package directory beneath " ,
79- getwd()
80- ), name = " console" )
81- stop(" exiting" , call. = FALSE )
67+ stop(
68+ paste(
69+ package_path ,
70+ " is not a valid R package directory beneath" ,
71+ getwd()
72+ )
73+ )
8274 }
8375 )
8476
8577 # Check that directory name matches package name
8678 validate_pkg_name(package_path )
8779
88- # Return success if we've processed everything
89- success <-
90- DataPackageR(arg = package_path , deps = deps )
91- ifelse(success ,
92- .multilog_trace(" DataPackageR succeeded" ),
93- .multilog_warn(" DataPackageR failed" )
94- )
95- .multilog_trace(" Building documentation" )
80+ # Process everything
81+ DataPackageR(arg = package_path , deps = deps )
82+
9683 local({
9784 on.exit({
9885 if (packageName %in% names(utils :: sessionInfo()$ otherPkgs )){
@@ -101,7 +88,6 @@ package_build <- function(packageName = NULL,
10188 })
10289 roxygen2 :: roxygenize(package_path , clean = TRUE )
10390 })
104- .multilog_trace(" Building package" )
10591 location <- pkgbuild :: build(path = package_path ,
10692 dest_path = dirname(package_path ),
10793 vignettes = vignettes ,
@@ -142,10 +128,8 @@ validate_pkg_name <- function(package_path){
142128 )$ get(" Package" )
143129 path_pkg_name <- basename(package_path )
144130 if (desc_pkg_name != path_pkg_name ){
145- err_msg <- paste(" Data package name in DESCRIPTION does not match" ,
146- " name of the data package directory" )
147- flog.fatal(err_msg , name = " console" )
148- stop(err_msg , call. = FALSE )
131+ stop(paste(" Data package name in DESCRIPTION does not match" ,
132+ " name of the data package directory" ))
149133 }
150134 desc_pkg_name
151135}
0 commit comments