From d15314689d2e31e06fb0aff8c8b5f4dafe82dc53 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 13 Dec 2024 13:01:40 +0200 Subject: [PATCH] Resolved an issue where the ``--project-dir`` flag did not function correctly with the check and debug commands // Resolve #5029 --- HISTORY.rst | 1 + platformio/check/cli.py | 9 ++++----- platformio/debug/cli.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8ef422a199..13adbdd512 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -25,6 +25,7 @@ test-driven methodologies, and modern toolchains for unrivaled success. * Ensured that dependencies of private libraries are no longer unnecessarily re-installed, optimizing dependency management and reducing redundant operations (`issue #4987 `_) * Resolved an issue where the ``compiledb`` target failed to properly escape compiler executable paths containing spaces (`issue #4998 `_) * Resolved an issue with incorrect path resolution when linking static libraries via the `build_flags `__ option (`issue #5004 `_) +* Resolved an issue where the ``--project-dir`` flag did not function correctly with the `pio check `__ and `pio debug `__ commands (`issue #5029 `_) 6.1.16 (2024-09-26) ~~~~~~~~~~~~~~~~~~~ diff --git a/platformio/check/cli.py b/platformio/check/cli.py index f4a4196140..ca591f0315 100644 --- a/platformio/check/cli.py +++ b/platformio/check/cli.py @@ -19,7 +19,6 @@ import os import shutil from collections import Counter -from os.path import dirname, isfile from time import time import click @@ -77,7 +76,7 @@ def cli( # pylint: disable=too-many-positional-arguments app.set_session_var("custom_project_conf", project_conf) # find project directory on upper level - if isfile(project_dir): + if os.path.isfile(project_dir): project_dir = find_project_dir_above(project_dir) results = [] @@ -150,7 +149,7 @@ def cli( # pylint: disable=too-many-positional-arguments print_processing_header(tool, envname, env_dump) ct = CheckToolFactory.new( - tool, project_dir, config, envname, tool_options + tool, os.getcwd(), config, envname, tool_options ) result = {"env": envname, "tool": tool, "duration": time()} @@ -250,12 +249,12 @@ def _append_defect(component, defect): components[component].update({DefectItem.SEVERITY_LABELS[defect.severity]: 1}) for defect in result.get("defects", []): - component = dirname(defect.file) or defect.file + component = os.path.dirname(defect.file) or defect.file _append_defect(component, defect) if component.lower().startswith(get_project_dir().lower()): while os.sep in component: - component = dirname(component) + component = os.path.dirname(component) _append_defect(component, defect) return components diff --git a/platformio/debug/cli.py b/platformio/debug/cli.py index f9229b4fbc..d29b44d066 100644 --- a/platformio/debug/cli.py +++ b/platformio/debug/cli.py @@ -86,7 +86,7 @@ def cli( # pylint: disable=too-many-positional-arguments if not interface: return helpers.predebug_project( - ctx, project_dir, project_config, env_name, False, verbose + ctx, os.getcwd(), project_config, env_name, False, verbose ) configure_args = ( @@ -106,7 +106,7 @@ def cli( # pylint: disable=too-many-positional-arguments else: debug_config = _configure(*configure_args) - _run(project_dir, debug_config, client_extra_args) + _run(os.getcwd(), debug_config, client_extra_args) return None