mirror of
https://github.com/agdamsbo/stRoke.git
synced 2024-10-29 19:01:53 +01:00
Delete ver_upd.R
This commit is contained in:
parent
5f430971c7
commit
7b7356add7
35
ver_upd.R
35
ver_upd.R
|
@ -1,35 +0,0 @@
|
||||||
updatePackageVersion <- function(packageLocation ="."){
|
|
||||||
## Seen at: https://www.mango-solutions.com/blog/how-to-auto-update-a-package-version-number
|
|
||||||
|
|
||||||
## Read DESCRIPTION file
|
|
||||||
desc <- readLines(file.path(packageLocation, "DESCRIPTION"))
|
|
||||||
|
|
||||||
## Find the line where the version is defined
|
|
||||||
vLine <- grep("^Version\\:", desc)
|
|
||||||
|
|
||||||
## Extract version number
|
|
||||||
vNumber <- gsub("^Version\\:\\s*", "", desc[vLine])
|
|
||||||
|
|
||||||
## Split the version number into two; a piece to keep, a piece to increment
|
|
||||||
versionNumber <- strsplit(vNumber, "\\.")[[1]]
|
|
||||||
versionParts <- length(versionNumber)
|
|
||||||
vNumberKeep <- paste(versionNumber[1:(versionParts-1)], sep= "", collapse= ".")
|
|
||||||
vNumberUpdate <- versionNumber[versionParts]
|
|
||||||
|
|
||||||
## Replace old version number with new one (increment by 1)
|
|
||||||
oldVersion <- as.numeric(vNumberUpdate)
|
|
||||||
newVersion <- oldVersion + 1
|
|
||||||
|
|
||||||
## Build final version number
|
|
||||||
vFinal <- paste(vNumberKeep, newVersion, sep = ".")
|
|
||||||
|
|
||||||
## Update DESCRIPTION file (in R)
|
|
||||||
desc[vLine] <- paste0("Version: ", vFinal )
|
|
||||||
|
|
||||||
## Update the actual DESCRIPTION file
|
|
||||||
writeLines(desc, file.path(packageLocation, "DESCRIPTION"))
|
|
||||||
|
|
||||||
## Return the updated version number to screen
|
|
||||||
return(vFinal)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user