Skip to content

Commit 962133f

Browse files
committed
mise-uv-init.py: send error output to stderr as well as the log
1 parent 7cb41c7 commit 962133f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

template/tasks/mise-uv-init.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,13 @@ def slugify(text):
7373

7474

7575
def print_log(*args, **kwargs):
76-
# TODO: would it be more helpful to print errors on stderr like mise/uv do?
7776
with paths.log().open('a') as fo:
78-
print(*args, file=fo)
77+
print(*args, file=fo, **kwargs)
78+
79+
80+
def print_err(*args, **kwargs):
81+
print(*args, file=sys.stderr, **kwargs)
82+
print_log(*args, **kwargs)
7983

8084

8185
def sub_run(*args, env=None) -> str:
@@ -85,10 +89,10 @@ def sub_run(*args, env=None) -> str:
8589
try:
8690
result = subprocess.run(args, check=True, text=True, capture_output=True, env=env)
8791
if result.stderr:
88-
print_log(args, '\n', result.stderr)
92+
print_err(args, '\n', result.stderr)
8993
except subprocess.CalledProcessError as e:
9094
if e.stderr:
91-
print_log(args, '\n', e.stderr)
95+
print_err(args, '\n', e.stderr)
9296
raise
9397

9498
return result.stdout.strip()

0 commit comments

Comments
 (0)