Skip to content

Commit

Permalink
Updated for staged install (#291)
Browse files Browse the repository at this point in the history
with R 3.6, staged install is the default
hardcoded config paths are changed to functions
see https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html
  • Loading branch information
KentonWhite authored Feb 26, 2019
1 parent 7c1399e commit 27affaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,18 @@
## File that specifies default config values to be used in load.project() if config items are missing
## from a particular ProjectTemplate directory (because e.g. it was created under a previous version of PT and
## migrate.project() hasnt been run yet)
.default.config.file <- system.file('defaults/config/default.dcf', package = 'ProjectTemplate')
.default.config.file <- function() system.file('defaults', 'config', 'default.dcf', package = 'ProjectTemplate')

## File that contains the default initial project configuration after create.project()
.new.config.file <- system.file('defaults/templates/full/config/global.dcf', package = 'ProjectTemplate')
.new.config.file <- function() system.file('defaults', 'templates', 'full', 'config', 'global.dcf', package = 'ProjectTemplate')

## File that contains the datatypes for the options in global.dcf
.config.types.file <- system.file('defaults/config/types.dcf', package = 'ProjectTemplate')
.config.types.file <- function() system.file('defaults', 'config', 'types.dcf', package = 'ProjectTemplate')

# read the default and new configurations
.default.config <- translate.dcf(.default.config.file)
.new.config <- translate.dcf(.new.config.file)
.config.types <- translate.dcf(.config.types.file)
.default.config <- translate.dcf(.default.config.file())
.new.config <- translate.dcf(.new.config.file())
.config.types <- translate.dcf(.config.types.file())

# load and validate the config and return a config object

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-migration.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ test_that('migrating a project with a missing config file results in a message t
suppressMessages(load.project())

# Get the default config
default_config <- .read.config(.default.config.file)
default_config <- .read.config(.default.config.file())
default_config$version <- .package.version()

# check the config is all the default
Expand Down Expand Up @@ -145,7 +145,7 @@ test_that('migrating a project with a missing config item results in a message t
suppressMessages(load.project())

# check the missing config item is the default value
default_config <- .read.config(.default.config.file)
default_config <- .read.config(.default.config.file())
expect_equal(get.project()$config$data_loading, default_config$data_loading)

tidy_up()
Expand Down

0 comments on commit 27affaa

Please sign in to comment.