Merge pull request #292 from chansonzhang/main

fix: windows compatibility
This commit is contained in:
geekan 2023-09-09 14:56:42 +08:00 committed by GitHub
commit cfc746b218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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