Improve string handling for NODE_OPTIONS and PYTHONPATH

Use filter(Boolean).join() to avoid extra spaces and properly handle
missing environment variables. This ensures clean paths even when
some variables are empty or undefined.

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-22 14:47:33 +00:00
parent ee7d39f433
commit ebedd994dd
2 changed files with 2 additions and 2 deletions

View File

@ -43,7 +43,7 @@ function run() {
// Export NODE_OPTIONS so task_before can use it for any node commands // Export NODE_OPTIONS so task_before can use it for any node commands
const nodeOptionsForBash = file_preload_js const nodeOptionsForBash = file_preload_js
? `-r ${file_preload_js} ${PREV_NODE_OPTIONS || ''}` ? ['-r', file_preload_js, PREV_NODE_OPTIONS].filter(Boolean).join(' ')
: PREV_NODE_OPTIONS || ''; : PREV_NODE_OPTIONS || '';
const commands = [ const commands = [

View File

@ -52,7 +52,7 @@ def run():
temp_file = f"/tmp/env_{os.getpid()}.json" temp_file = f"/tmp/env_{os.getpid()}.json"
# Export PYTHONPATH so task_before can use it for any python commands # Export PYTHONPATH so task_before can use it for any python commands
pythonpath_for_bash = f"{dir_preload}:{dir_config}:{prev_pythonpath}" if dir_preload else prev_pythonpath pythonpath_for_bash = ':'.join(filter(None, [dir_preload, dir_config, prev_pythonpath]))
# 构建命令数组 # 构建命令数组
commands = [ commands = [