Merge branch 'geekan:main' into main

This commit is contained in:
Steven Lee 2023-09-11 10:10:14 +08:00 committed by GitHub
commit 65db088245
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 55 additions and 31 deletions

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