fix: windows compatibility

This commit is contained in:
Chen Zhang 2023-09-06 17:47:35 +08:00
parent de1a7dcfc7
commit c0aab24b29

View file

@ -9,6 +9,7 @@ import ast
import contextlib
import inspect
import os
import platform
import re
from typing import List, Tuple
@ -20,7 +21,10 @@ def check_cmd_exists(command) -> int:
:param command: 待检查的命令
:return: 如果命令存在返回0如果不存在返回非0
"""
check_command = 'command -v ' + command + ' >/dev/null 2>&1 || { echo >&2 "no mermaid"; exit 1; }'
if platform.system().lower() == 'windows':
check_command = 'where ' + command
else:
check_command = 'command -v ' + command + ' >/dev/null 2>&1 || { echo >&2 "no mermaid"; exit 1; }'
result = os.system(check_command)
return result