Skip to content

Commit

Permalink
bin/nvh: Add "forced on" state for xz
Browse files Browse the repository at this point in the history
Skips node version checks, which would otherwise gate xz usage.

In other words:
Overrides any checks that would normally be run,
so that nvh always attempts to use xz.

---

Partly adapted from this comment (with liberties taken on implementation):
shadowspawn#8 (comment)

Co-authored-by: John Gee <john@ruru.gen.nz>

---

Also updates "--use-xz" to not set the "xz forced on" state.
(This matches the flag's description in the help messages.)
  • Loading branch information
DeeDeeG committed Sep 22, 2019
1 parent d33955d commit d315b3d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions bin/nvh
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ NVH_NODE_DOWNLOAD_MIRROR=${NVH_NODE_DOWNLOAD_MIRROR:-https://nodejs.org/download
NVH_NODE_DOWNLOAD_MIRROR=${NVH_NODE_DOWNLOAD_MIRROR%/}
readonly NVH_NODE_DOWNLOAD_MIRROR

# Enabled by default. User may set NVH_USE_XZ to 0 to disable.
# Normalise to true/false.
# Using xz instead of gzip is enabled by default, if xz compatibility checks pass.
# User may set NVH_USE_XZ to 0 to disable, or set to anything else to force-enable.
# May be overridden by command line flags.

g_xz_force_enabled="false"
if [[ "${NVH_USE_XZ}" = "0" ]]; then
NVH_USE_XZ="false"
elif [[ -n "${NVH_USE_XZ+defined}" ]]; then
NVH_USE_XZ="true"
g_xz_force_enabled="true"
else
NVH_USE_XZ="true"
fi
Expand Down Expand Up @@ -686,12 +690,14 @@ function install() {
fi
fi

[[ "${NVH_USE_XZ}" = "true" ]] && can_use_xz "${resolved_version}" || NVH_USE_XZ="false"
if [[ "${NVH_USE_XZ}" = true ]] && [[ "S{g_xz_force_enabled}" = "false" ]]; then
can_use_xz || NVH_USE_XZ="false"
fi

echo
install_log "installing" "${g_mirror_folder_name}/${resolved_version}"

if [[ "${NVH_USE_XZ}" = "true" ]]; then
if [[ "${NVH_USE_XZ}" = "true" ]] && [[ "${g_xz_force_enabled}" = "false" ]]; then
local resolved_major_version
resolved_major_version="$(echo ${resolved_version#v} | cut -d '.' -f '1')"
if [[ "${resolved_major_version}" -lt 4 ]]; then
Expand Down Expand Up @@ -1193,7 +1199,7 @@ function main() {
--insecure) set_insecure ;;
-p|--preserve) NVH_PRESERVE_NPM="true" ;;
--no-preserve) NVH_PRESERVE_NPM="" ;;
--use-xz) NVH_USE_XZ="true" ;;
--use-xz) NVH_USE_XZ="true"; g_xz_force_enabled="false" ;;
--no-use-xz) NVH_USE_XZ="false" ;;
-V|--version) echo "${VERSION}"; exit ;;
-*) abort "unrecognised option '$1'"; exit 1 ;;
Expand Down

0 comments on commit d315b3d

Please sign in to comment.