Skip to content

Commit

Permalink
fix styling of all R scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bernt-matthias authored and TomHarrop committed Sep 24, 2024
1 parent 3351042 commit 85b9ab7
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .github/styler.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ library("styler")

parser <- ArgumentParser(description = "Call styler")
parser$add_argument("dir",
metavar = "DIR", type = "character",
help = "File to parse"
metavar = "DIR", type = "character",
help = "File to parse"
)
parser$add_argument("--dry",
choices = c("off", "on"), default = "on"
choices = c("off", "on"), default = "on"
)
args <- parser$parse_args()

file_info <- file.info(args$dir)
is_directory <- file_info$isdir

if(is_directory){
if (is_directory) {
captured_output <- capture.output({
result <- style_dir(args$dir, indent_by = 4, dry = args$dry, recursive = TRUE)
})
}else{
} else {
captured_output <- capture.output({
result <- style_file(args$dir, indent_by = 4, dry = args$dry)
})
}

n <- nrow(subset(result, changed == TRUE))
if(n > 0){
if(args$dry == "off"){
if (n > 0) {
if (args$dry == "off") {
print(paste("Changed", n, "files"))
}else{
} else {
stop(paste("Linting failed for", n, "files"))
}
}
}

0 comments on commit 85b9ab7

Please sign in to comment.