Fix composer require completion

When no development dependencies are installed, the completion would crash with:

    KeyError: 'require-dev'
This commit is contained in:
Jan Tojnar 2023-04-12 20:45:50 +02:00 committed by Fabian Boehm
parent bda9d57417
commit 9e223577aa

View file

@ -29,7 +29,7 @@ import json
json_data = open('composer.json')
data = json.load(json_data)
json_data.close()
packages = itertools.chain(data['require'].keys(), data['require-dev'].keys())
packages = itertools.chain(data.get('require', {}).keys(), data.get('require-dev', {}).keys())
print(\"\n\".join(packages))
" | $python -S
end