fix(qmd): treat a missing global npm prefix as not installed
On a machine where no global npm package was ever installed, the global prefix directory does not exist and `npm list --global --json` reports ENOENT without a dependency list. QMD setup treated that as an unreliable listing and failed the install/update. It now means the package is not installed; other unreliable listings still fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6fd4dde7d
commit
a89be2604b
2 files changed
+10
No files matched your search
@@ -101,6 +101,11 @@ class Setup:
|
||||
listing = json.loads(output)
|
||||
except json.JSONDecodeError:
|
||||
raise ValueError('npm list did not return JSON.')
|
||||
# Before the first global install the global prefix directory does not exist; npm then
|
||||
# reports ENOENT without a dependency list, which means nothing is installed yet.
|
||||
error = listing.get('error') if isinstance(listing, dict) else None
|
||||
if isinstance(error, dict) and error.get('code') == 'ENOENT' and 'dependencies' not in listing:
|
||||
return False
|
||||
if not isinstance(listing, dict) or not isinstance(listing.get('dependencies'), dict):
|
||||
raise ValueError('npm list did not report the global packages.')
|
||||
return PACKAGE in listing['dependencies']
|
||||
|
||||
Reference in new issue
Block a user