X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/b542f589a5c4041f54847591104cd51684849f2e..5d5bf6e0878539baeef797b87636235b8c02be3f:/action/main.py?ds=sidebyside diff --git a/action/main.py b/action/main.py index 23c3a65..c0af393 100644 --- a/action/main.py +++ b/action/main.py @@ -1,5 +1,6 @@ import os import shlex +import shutil import sys from pathlib import Path from subprocess import PIPE, STDOUT, run @@ -32,7 +33,7 @@ else: describe_name = line[len("describe-name: ") :].rstrip() break if not describe_name: - print("::error::Failed to detect action version.", flush=True) + print("::error::Failed to detect action version.", file=sys.stderr, flush=True) sys.exit(1) # expected format is one of: # - 23.1.0 @@ -53,15 +54,26 @@ pip_proc = run( ) if pip_proc.returncode: print(pip_proc.stdout) - print("::error::Failed to install Black.", flush=True) + print("::error::Failed to install Black.", file=sys.stderr, flush=True) sys.exit(pip_proc.returncode) base_cmd = [str(ENV_BIN / "black")] if BLACK_ARGS: # TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS. - proc = run([*base_cmd, *shlex.split(BLACK_ARGS)]) + proc = run( + [*base_cmd, *shlex.split(BLACK_ARGS)], + stdout=PIPE, + stderr=STDOUT, + encoding="utf-8", + ) else: - proc = run([*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)]) - + proc = run( + [*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)], + stdout=PIPE, + stderr=STDOUT, + encoding="utf-8", + ) +shutil.rmtree(ENV_PATH, ignore_errors=True) +print(proc.stdout) sys.exit(proc.returncode)