This commit is contained in:
ovcharenko 2025-12-26 21:14:01 -05:00 committed by GitHub
commit dc61db082d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import contextlib
import errno
import importlib.resources
import os.path
import re
import shutil
import stat
import subprocess
@ -237,3 +238,13 @@ else: # pragma: >=3.12 cover
def win_exe(s: str) -> str:
return s if sys.platform != 'win32' else f'{s}.exe'
def get_npm_version() -> tuple[int, ...]:
_, out, _ = cmd_output('npm', '--version')
version_match = re.match(r'^(\d+)\.(\d+)\.(\d+)', out)
if version_match is None:
return 0, 0, 0
else:
return tuple(map(int, version_match.groups()))