diff --git a/nupm/install.nu b/nupm/install.nu index 6f85463..eb554ee 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -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' { diff --git a/nupm/search.nu b/nupm/search.nu index e4dc200..b751a35 100644 --- a/nupm/search.nu +++ b/nupm/search.nu @@ -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| { @@ -24,4 +24,6 @@ export def main [ } } | filter-by-version $pkg_version + + return $result } diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index 4dcb552..6f3936f 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -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