don't error if only dependencies or devDependencies are present (#10594)

This commit is contained in:
Kendell R 2024-06-29 16:01:41 -07:00 committed by GitHub
parent 8f563846e8
commit 2a0f7e411f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,7 +77,7 @@ function __npm_installed_local_packages
if set -l python (__fish_anypython) if set -l python (__fish_anypython)
$python -S -c 'import json, sys; data = json.load(sys.stdin); $python -S -c 'import json, sys; data = json.load(sys.stdin);
print("\n".join(data["dependencies"])); print("\n".join(data["devDependencies"]))' <$package_json 2>/dev/null print("\n".join(data.get("dependencies", []))); print("\n".join(data.get("devDependencies", [])))' <$package_json 2>/dev/null
else if type -q jq else if type -q jq
jq -r '.dependencies as $a1 | .devDependencies as $a2 | ($a1 + $a2) | to_entries[] | .key' $package_json jq -r '.dependencies as $a1 | .devDependencies as $a2 | ($a1 + $a2) | to_entries[] | .key' $package_json
else else