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

845 path/pkg arg consistency #1048

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ get_current_config <- function(path = getwd()) {
# set the {golem} name
change_app_config_name <- function(
name,
path = get_golem_wd()
pkg = get_golem_wd()
) {
pth <- fs_path(path, "R", "app_config.R")
pth <- fs_path(pkg, "R", "app_config.R")
app_config <- readLines(pth)

where_system.file <- grep("system.file", app_config)
Expand Down
2 changes: 1 addition & 1 deletion R/desc.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fill_desc <- function(
)
change_app_config_name(
name = pkg_name,
path = pkg
pkg = pkg
)
set_golem_name(pkg_name)

Expand Down
16 changes: 8 additions & 8 deletions R/golem-yaml-get.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ get_golem_things <- function(
)
),
use_parent = TRUE,
path
pkg
) {
conf_path <- get_current_config(
path
pkg
)
stop_if(
conf_path,
Expand All @@ -34,13 +34,13 @@ get_golem_wd <- function(
use_parent = TRUE,
pkg = golem::pkg_path()
) {
path <- fs_path_abs(pkg)
pkg <- fs_path_abs(pkg)

pth <- get_golem_things(
value = "golem_wd",
config = "dev",
use_parent = use_parent,
path = path
pkg = pkg
)
if (is.null(pth)) {
pth <- golem::pkg_path()
Expand All @@ -61,12 +61,12 @@ get_golem_name <- function(
use_parent = TRUE,
pkg = golem::pkg_path()
) {
path <- fs_path_abs(pkg)
pkg <- fs_path_abs(pkg)
nm <- get_golem_things(
value = "golem_name",
config = config,
use_parent = use_parent,
path = path
pkg = pkg
)
if (is.null(nm)) {
nm <- golem::pkg_name()
Expand All @@ -87,12 +87,12 @@ get_golem_version <- function(
use_parent = TRUE,
pkg = golem::pkg_path()
) {
path <- fs_path_abs(pkg)
pkg <- fs_path_abs(pkg)
vers <- get_golem_things(
value = "golem_version",
config = config,
use_parent = use_parent,
path = path
pkg = pkg
)
if (is.null(vers)) {
vers <- golem::pkg_version()
Expand Down
22 changes: 11 additions & 11 deletions R/golem-yaml-set.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set_golem_name <- function(
talkative = TRUE,
old_name = golem::pkg_name()
) {
path <- fs_path_abs(pkg)
pkg <- fs_path_abs(pkg)

# Changing in YAML
amend_golem_config(
Expand All @@ -48,13 +48,13 @@ set_golem_name <- function(
# Changing in app-config.R
change_app_config_name(
name = name,
path = path
pkg = pkg
)

# Changing in DESCRIPTION
desc <- desc_description(
file = fs_path(
path,
pkg,
"DESCRIPTION"
)
)
Expand All @@ -69,14 +69,14 @@ set_golem_name <- function(
set_golem_name_tests(
old_name = old_name,
new_name = name,
path = path
pkg = pkg
)

# Changing in ./vignettes/ if dir present
set_golem_name_vignettes(
old_name = old_name,
new_name = name,
path = path
pkg = pkg
)

if (old_name != name){
Expand All @@ -94,10 +94,10 @@ set_golem_name <- function(
set_golem_name_tests <- function(
old_name,
new_name,
path
pkg
) {
pth_dir_tests <- file.path(
path,
pkg,
"tests"
)

Expand All @@ -116,10 +116,10 @@ set_golem_name_tests <- function(
set_golem_name_vignettes <- function(
old_name,
new_name,
path
pkg
) {
pth_dir_vignettes <- file.path(
path,
pkg,
"vignettes"
)

Expand Down Expand Up @@ -151,7 +151,7 @@ set_golem_version <- function(
pkg = golem::pkg_path(),
talkative = TRUE
) {
path <- fs_path_abs(pkg)
pkg <- fs_path_abs(pkg)

# Changing in YAML
amend_golem_config(
Expand All @@ -164,7 +164,7 @@ set_golem_version <- function(

desc <- desc_description(
file = fs_path(
path,
pkg,
"DESCRIPTION"
)
)
Expand Down
8 changes: 4 additions & 4 deletions R/is_golem.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#' Is the directory a golem-based app?
#'
#' Trying to guess if `path` is a golem-based app.
#' Trying to guess if `pkg` is a golem-based app.
#'
#' @param path Path to the directory to check.
#' @param pkg Path to the directory to check.
#' Defaults to the current working directory.
#'
#' @export
#'
#' @examples
#' is_golem()
is_golem <- function(path = getwd()) {
is_golem <- function(pkg = getwd()) {
files_from_shiny_example <- grep(
"^(?!REMOVEME).*",
list.files(
Expand All @@ -28,6 +28,6 @@ is_golem <- function(path = getwd()) {
)

all(
files_from_shiny_example %in% list.files(path, recursive = TRUE)
files_from_shiny_example %in% list.files(pkg, recursive = TRUE)
)
}
14 changes: 7 additions & 7 deletions R/pkg_tools.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Getting the DESCRIPTION file in a data.frame
daf_desc <- function(
path = get_golem_wd(),
pkg = get_golem_wd(),
entry) {
as.character(
unlist(
unname(
as.data.frame(
read.dcf(
normalizePath(
fs_path(path, "DESCRIPTION")
fs_path(pkg, "DESCRIPTION")
)
)
)[entry]
Expand All @@ -22,19 +22,19 @@ daf_desc <- function(
#' These are functions to help you navigate
#' inside your project while developing
#'
#' @param path Path to use to read the DESCRIPTION
#' @param pkg Path to use to read the DESCRIPTION
#'
#' @export
#' @rdname pkg_tools
#'
#' @return The value of the entry in the DESCRIPTION file
pkg_name <- function(path = get_golem_wd()) {
daf_desc(path, "Package")
pkg_name <- function(pkg = get_golem_wd()) {
daf_desc(pkg, "Package")
}
#' @export
#' @rdname pkg_tools
pkg_version <- function(path = get_golem_wd()) {
daf_desc(path, "Version")
pkg_version <- function(pkg = get_golem_wd()) {
daf_desc(pkg, "Version")
}
#' @export
#' @rdname pkg_tools
Expand Down
6 changes: 3 additions & 3 deletions man/is_golem.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/pkg_tools.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.