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

rstudio version check bug fix #100

Merged
merged 4 commits into from
Nov 15, 2024
Merged
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
16 changes: 14 additions & 2 deletions R/new_script.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ new_script <- function() {
default = Sys.info()[["user"]]
)

if (is.null(author)) {
stop("Please enter a name for the script author")
}

git <- rstudioapi::showQuestion(
title = "Git",
message = "Are you version controlling using git?",
Expand All @@ -33,9 +37,17 @@ new_script <- function() {
r_code <- paste0(r_code_part1, r_code_part2, collapse = "")
}

if (!is.null(author) && rstudioapi::getVersion() >= 1.2) {
dated_version <- grepl("[0-9]{4}\\.[0-9]+\\.", rstudioapi::getVersion())

if (dated_version) {
required_version <- TRUE
} else {
required_version <- rstudioapi::getVersion() >= 1.2
}

if (required_version) {
invisible(rstudioapi::documentNew(r_code, type = "r"))
} else if (!is.null(author) && rstudioapi::getVersion() < 1.2) {
} else {
filename <- rstudioapi::showPrompt(
title = "Filename",
message = "Filename for new script\nYou can choose a folder to store this in after this",
Expand Down
Loading