Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions bin/n
Original file line number Diff line number Diff line change
Expand Up @@ -1084,9 +1084,14 @@ function get_package_engine_version() {
g_target_node=
local filepath="$1"
verbose_log "found" "${filepath}"
command -v node &> /dev/null || abort "an active version of node is required to read 'engines' from package.json"
local range
range="$(node -e "package = require('${filepath}'); if (package && package.engines && package.engines.node) console.log(package.engines.node)")"
if command -v jq &> /dev/null; then
range="$(jq -r '.engines.node // ""' < "${filepath}")"
elif command -v node &> /dev/null; then
range="$(node -e "package = require('${filepath}'); if (package && package.engines && package.engines.node) console.log(package.engines.node)")"
else
abort "either jq or an active version of node is required to read 'engines' from package.json"
fi
verbose_log "read" "${range}"
[[ -n "${range}" ]] || return 2
if [[ "*" == "${range}" ]]; then
Expand Down Expand Up @@ -1474,6 +1479,13 @@ function show_diagnostics() {
echo_red "Neither curl nor wget found. Need one of them for downloads."
fi

printf "\njq\n"
if command -v jq &> /dev/null; then
command -v jq && jq --version
else
echo "jq not found, can be used to get package.json values faster than node"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "jq not found, can be used to get package.json values faster than node"
echo "jq not found. Optional install used for reading engine version from package.json."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't mind the phrasing -- I forgot to say that you should make it whatever fits...

fi

printf "\nuname\n"
uname -a

Expand Down