From edda65c0c0307e50e981c6faeed224b0ae4fcca2 Mon Sep 17 00:00:00 2001 From: Jonathan Bernard Date: Thu, 17 Jul 2025 13:16:05 -0500 Subject: [PATCH] Add --skip-package-file option. --- update_version.nim | 32 +++++++++++++++++++++++++++----- update_version.nimble | 2 +- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/update_version.nim b/update_version.nim index 9c2da71..bce3e01 100644 --- a/update_version.nim +++ b/update_version.nim @@ -22,6 +22,25 @@ Options: bump. Valid options are: 'major', 'minor', 'patch', 'prerelease', 'buildmetadata', and 'last'. Defaults to 'last' + + --skip-package-file Don't write changes to the package file (*.nimble or + package.json). This is useful mostly in temporary + circumstances where you want to update other source + files without updating the package file. Be careful + in these cases, however, as update_version uses the + current version (as reported in the package file) as + the canonical version. When updating versions in + other source files, update_version ignores lines that + do not match the current version. Consider the + following: + + update_version set 1.0.4 file1.nim, file2.nim --skip-package-file # works + update_version set 1.0.0 file1.nim, file2.nim --skip-package-file # fails + + The second command will *not* rewrite the version + strings in file1.nim and file2.nim because the + versions in those files (1.0.4) do not match what is + in the package. Details: bump @@ -66,7 +85,7 @@ Details: Node: ^\s*export\s+const\s+\S*VERSION\S*\s*=\s*"()"\s*;?$ """ -const UV_VERSION = "1.1.0" +const UV_VERSION = "1.2.0" type LangType* = enum lNim, lNode @@ -313,7 +332,8 @@ when isMainModule: let part = parseSemverPart(partName) pkg.version = incrementSemverPart(pkg.version, part) - writePackage(pkg) + if not args["--skip-package-file"]: + writePackage(pkg) for filePath in args[""]: replaceVersionInFile(Path(filePath), pkg, oldVersion) @@ -333,7 +353,8 @@ when isMainModule: for filePath in args[""]: replaceVersionInFile(Path(filePath), pkg, oldVersion) - writePackage(pkg) + if not args["--skip-package-file"]: + writePackage(pkg) echo pkg.version elif args["get"]: echo pkg.version @@ -349,8 +370,9 @@ when isMainModule: let isCorrect = stdin.readLine acceptNewVersion = "yes".startsWith(isCorrect.toLower) - echo "Updating version definition in " & $pkg.file - writePackage(pkg) + if not args["--skip-package-file"]: + echo "Updating version definition in " & $pkg.file + writePackage(pkg) for filePath in args[""]: echo "Updating version definition in " & $filePath diff --git a/update_version.nimble b/update_version.nimble index b08a5fb..9ce33dd 100644 --- a/update_version.nimble +++ b/update_version.nimble @@ -1,6 +1,6 @@ # Package -version = "1.1.0" +version = "1.2.0" author = "Jonathan Bernard" description = "Small util to update version consistently for nim and node packages." license = "MIT"