Skip to content

Commit

Permalink
Fail for blank target from auto (or engine) version file (tj#693)
Browse files Browse the repository at this point in the history
* Fail unspecified auto rather than fall back to current

* Simplify wording
  • Loading branch information
shadowspawn authored Oct 16, 2021
1 parent cc4d331 commit d272114
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/n
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,8 @@ function get_package_engine_version() {
local range
range="$(node -e "package = require('${filepath}'); if (package && package.engines && package.engines.node) console.log(package.engines.node)")"
verbose_log "read" "${range}"
if [[ -z "${range}" || "*" == "${range}" ]]; then
[[ -n "${range}" ]] || return 2
if [[ "*" == "${range}" ]]; then
verbose_log "target" "current"
g_target_node="current"
return
Expand Down Expand Up @@ -1142,6 +1143,7 @@ function get_engine_version() {
break
done
[[ -n "${parent}" ]] || abort "${error_message}"
[[ -n "${g_target_node}" ]] || abort "did not find supported version of node in 'engines' field of package.json"
}

#
Expand Down Expand Up @@ -1169,6 +1171,7 @@ function get_auto_version() {
done
# Fallback to package.json
[[ -n "${parent}" ]] || get_engine_version "no file found for auto version (.n-node-version, .node-version, .nvmrc, or package.json)"
[[ -n "${g_target_node}" ]] || abort "file found for auto did not contain target version of node"
}

#
Expand Down

0 comments on commit d272114

Please sign in to comment.