diff --git a/nupm/install.nu b/nupm/install.nu index 5e909db..29c7197 100644 --- a/nupm/install.nu +++ b/nupm/install.nu @@ -207,11 +207,6 @@ 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 4da4ca5..9e32693 100644 --- a/nupm/search.nu +++ b/nupm/search.nu @@ -10,22 +10,18 @@ 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 + search-package $package --registry $registry --exact-match=$exact_match --skip-dirty-pkg | flatten | each {|row| - 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 - } + { + 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 } } - | compact | filter-by-version $pkg_version + | filter-by-version $pkg_version } diff --git a/nupm/utils/registry.nu b/nupm/utils/registry.nu index 7aed847..f9ac1c0 100644 --- a/nupm/utils/registry.nu +++ b/nupm/utils/registry.nu @@ -8,13 +8,14 @@ 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 dirty ] +export const REG_PKG_COLS = [ name version path type info ] # Search for a package in a registry export def search-package [ package: string # Name of the package --registry: string # Which registry to use (name or path) --exact-match # Searched package name must match exactly + --skip-dirty-pkg # Skip packages with failed hash checks ] -> table { let registries = if (not ($registry | is-empty)) and ($registry in $env.NUPM_REGISTRIES) { # If $registry is a valid column in $env.NUPM_REGISTRIES, use that @@ -86,11 +87,19 @@ export def search-package [ let new_hash = $pkg_file_path | hash-file - # check package hash let dirty = $new_hash != $row.hash - - open $pkg_file_path | insert dirty $dirty + if $new_hash != $row.hash { + if $skip_dirty_pkg { + null + } else { + throw-error ($'Content of package file `($url_or_path)' + + $' does not match expected hash `($row.hash)`.') + } + } else { + open $pkg_file_path | insert dirty $dirty + } } + | compact | flatten {