Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions nupm/install.nu
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ def fetch-package [
throw-error $'No package matching version `($version)`'
}

if $pkg.hash_mismatch == true {
throw-error ($'Content of package file ($pkg.path)'
+ $' does not match expected hash')
}

print $pkg

if $pkg.type == 'git' {
Expand Down
4 changes: 3 additions & 1 deletion nupm/search.nu
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export def main [
--pkg-version(-v): string # Package version to install
--exact-match(-e) # Match package name exactly
]: nothing -> table {
search-package $package --registry $registry --exact-match=$exact_match
let result = search-package $package --registry $registry --exact-match=$exact_match
| flatten
| each {|row|
{
Expand All @@ -24,4 +24,6 @@ export def main [
}
}
| filter-by-version $pkg_version

return $result
}
10 changes: 3 additions & 7 deletions nupm/utils/registry.nu
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,15 @@ export def search-package [

let new_hash = open $pkg_file_path | to nuon | hash-fn

if $new_hash != $row.hash {
throw-error ($'Content of package file ($pkg_file_path)'
+ $' does not match expected hash ($row.hash)')
}

open $pkg_file_path
open $pkg_file_path | insert hash_mismatch ($new_hash != $row.hash)
}
| compact
| flatten

{
registry_name: $name
registry_path: $registry.path
pkgs: $pkgs
pkgs: $pkgs,
}
}
| compact
Expand Down