diff --git a/nupm/install.nu b/nupm/install.nu index 29c7197..5e909db 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.dirty { + 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..4da4ca5 100644 --- a/nupm/search.nu +++ b/nupm/search.nu @@ -13,15 +13,19 @@ export def main [ search-package $package --registry $registry --exact-match=$exact_match | flatten | each {|row| - { - registry_name: $row.registry_name - registry_path: $row.registry_path - name: $row.pkgs.name - version: $row.pkgs.version - path: $row.pkgs.path - type: $row.pkgs.type - info: $row.pkgs.info + if $row.pkgs.dirty { + null + } else { + { + registry_name: $row.registry_name + registry_path: $row.registry_path + name: $row.pkgs.name + version: $row.pkgs.version + path: $row.pkgs.path + type: $row.pkgs.type + info: $row.pkgs.info + } } } - | filter-by-version $pkg_version + | compact | filter-by-version $pkg_version } diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index 006e105..7aed847 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -8,7 +8,7 @@ use misc.nu [check-cols url hash-file] export const REG_COLS = [ name path hash ] # Columns of a registry package file -export const REG_PKG_COLS = [ name version path type info ] +export const REG_PKG_COLS = [ name version path type info dirty ] # Search for a package in a registry export def search-package [ @@ -86,19 +86,17 @@ export def search-package [ let new_hash = $pkg_file_path | hash-file - if $new_hash != $row.hash { - throw-error ($'Content of package file ($pkg_file_path)' - + $' does not match expected hash ($row.hash)') - } + # check package hash + let dirty = $new_hash != $row.hash - open $pkg_file_path + open $pkg_file_path | insert dirty $dirty } | flatten { registry_name: $name registry_path: $registry.path - pkgs: $pkgs + pkgs: $pkgs, } } | compact