Skip to content

Commit

Permalink
fix package directory name strip
Browse files Browse the repository at this point in the history
  • Loading branch information
TD-Sky committed Dec 24, 2024
1 parent 9f70e6b commit b30e575
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions update.nu
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ def main [
--keep (-k), # Keep old version
] {
# The actually name for version check
let project = $package
| path basename
| split row '-'
| first
let dir = $package | path basename
let project = $dir
| str strip-suffix '-bin'
| default ($dir | str strip-suffix '-git')
| default $dir

# Check the new verions according to `nvchecker.toml`;
# if upstream has upgraded, update `new_ver.json`;
Expand Down Expand Up @@ -56,3 +57,13 @@ def main [
nvtake $project -c nvchecker.toml
}
}

def 'str strip-suffix' [
suffix: string
]: string -> string {
let self = $in
if ($self | str ends-with $suffix) {
let i = $self | str index-of -e $suffix
$self | str substring ..<$i
}
}

0 comments on commit b30e575

Please sign in to comment.