From 372447c48b1f7eff709758ba44829dc7c5add67d Mon Sep 17 00:00:00 2001 From: SaintFTS <152052965+SaintFTS@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:46:05 +0500 Subject: [PATCH] Better export.ps1 Now, if you want to add this ps1 file to the $PATH without adding other scripts, like install.ps1, you can now just drag it in some empty directory and add it to the $PATH. Just define $IDF_PATH. Suggestion to define $IDF_PATH was already in the script, but It didn't work because $IDF_PATH was just set to the root of the script ("$PSScriptRoot"). I also added more "clean" exit out of a script - it won't just scrap $IDF_PATH enviroment variable if it didn't find python scripts. --- export.ps1 | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/export.ps1 b/export.ps1 index 5e54c4437e1b..784e2c2a39dc 100644 --- a/export.ps1 +++ b/export.ps1 @@ -7,17 +7,22 @@ if ($env:ESP_IDF_LEGACY_EXPORT) { exit $LASTEXITCODE } -$idf_path = "$PSScriptRoot" +if ("$env:IDF_PATH" -ne "") { + $idf_path = "$env:IDF_PATH" +} else { + Write-Output "No IDF_PATH enviroment variable detected. Using the root directory as IDF_PATH" + $idf_path = "$PSScriptRoot" +} if (-not (Test-Path "$idf_path/tools/idf.py") -or -not (Test-Path "$idf_path/tools/idf_tools.py") -or -not (Test-Path "$idf_path/tools/activate.py")) { - - Write-Output "Could not detect IDF_PATH. Please navigate to your ESP-IDF directory and run:" - Write-Output ".\export.ps1" - - $env:IDF_PATH = "" - + + Write-Output "`"$idf_path`" doesn't contain needed scripts. Please, add IDF_PATH enviroment variable:" + Write-Output ' $env:IDF_PATH=(add path here), ' + Write-Output 'or navigate to your ESP-IDF directory and run:' + Write-Output ' .\export.ps1' + exit 1 }