Skip to content

Commit

Permalink
use different versions of file.edit depending on OS and IDE (closes t…
Browse files Browse the repository at this point in the history
  • Loading branch information
crew102 committed Sep 13, 2018
1 parent 6424afb commit 226ff2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/reprex.R
Expand Up @@ -374,7 +374,7 @@ reprex <- function(x = NULL,
" * ", reprex_file
)
if (yep("Open the output file for manual copy?")) {
withr::defer(utils::file.edit(reprex_file))
withr::defer(file_edit2(reprex_file))
}
}

Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Expand Up @@ -89,3 +89,15 @@ inject_file <- function(path, inject_path, pre_process = enfence, ...) {
prose <- function(x) {
paste0("#' ", x)
}

is_windows <- function() {
grepl("windows", Sys.info()[["sysname"]], ignore.case = TRUE)
}

file_edit2 <- function(file) {
if (is_windows()) {
get("file.edit")(file)
} else {
utils::file.edit(file)
}
}

0 comments on commit 226ff2b

Please sign in to comment.