diff --git a/lib.sh b/lib.sh index 49331a9..02a7472 100644 --- a/lib.sh +++ b/lib.sh @@ -3,29 +3,31 @@ # lib_get_esptool_command() { WIN_PYTHON="python" - if command -v esptool.py &> /dev/null + MAC_ESPTOOL="esptool" + if command -v $MAC_ESPTOOL &> /dev/null then - echo "esptool.py" + echo "$MAC_ESPTOOL" + return else - if ! command -v $WIN_PYTHON &> /dev/null - then - $WIN_PYTHON - echo "エラー:Pythonコマンドを使用するため、まずPythonをインストールしてください。" - echo "esptool.py nor $WIN_PYTHON could not be found. Please install it first." - exit 1 - else - # check if esptool is installed as a module - if $WIN_PYTHON -m esptool --help &> /dev/null + if ! command -v $WIN_PYTHON &> /dev/null then - echo "$WIN_PYTHON -m esptool" - return + $WIN_PYTHON + echo "エラー:Pythonコマンドを使用するため、まずPythonをインストールしてください。" + echo "$MAC_ESPTOOL nor $WIN_PYTHON could not be found. Please install it first." + exit 1 else - $WIN_PYTHON -m pip install --upgrade pip - $WIN_PYTHON -m pip install esptool --no-warn-script-location - return + # check if esptool is installed as a module + if $WIN_PYTHON -m esptool --help &> /dev/null + then + echo "$WIN_PYTHON -m esptool" + return + else + $WIN_PYTHON -m pip install --upgrade pip + $WIN_PYTHON -m pip install esptool --no-warn-script-location + return + fi + echo "$WIN_PYTHON -m esptool" fi - echo "$WIN_PYTHON -m esptool" - fi fi }