Skip to content

Commit 264dc24

Browse files
committed
fix: cache unchanged login shell PATH
1 parent ab7fede commit 264dc24

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎scripts/detect_lang.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ def _node_available() -> bool:
8383
)
8484
if proc.returncode == 0:
8585
inherited = proc.stdout.strip().splitlines()
86-
if inherited and inherited[-1].count(":") > cur.count(":"):
87-
os.environ["PATH"] = inherited[-1]
86+
if inherited:
87+
# 即使登录 shell 没提供更丰富的 PATH,也缓存这次探测结果。
88+
# Linux CI 的 login shell 常与当前 PATH 等价;若不写缓存,
89+
# 每次钩子都会重复 spawn shell,违背十分钟缓存契约。
90+
resolved = inherited[-1] if inherited[-1].count(":") > cur.count(":") else os.environ["PATH"]
91+
os.environ["PATH"] = resolved
8892
try:
89-
cache_file.write_text(inherited[-1])
93+
cache_file.write_text(resolved)
9094
except OSError:
9195
pass
9296
except (OSError, subprocess.SubprocessError):

0 commit comments

Comments
 (0)