Skip to content

Commit

Permalink
Log codemodder errors and exit
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Dec 20, 2023
1 parent 1637f88 commit 45e8ed5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pixee/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,22 @@ def run_codemodder(
)
command = subprocess.Popen(
[codemodder, "--output", codetf.name, path] + common_codemodder_args,
stderr=subprocess.DEVNULL,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE if not verbose else None,
)
if command.stdout:
for line in iter(command.stdout.readline, b""):
if line.startswith(b"running codemod"):
progress.advance(task)
command.wait()
if command.returncode != 0:
console.print(
f"Error running codemodder: {codemodder} (exit code {command.returncode})"
)
if command.stderr:
console.print(command.stderr.read().decode("utf-8"))
sys.exit(1)

progress.update(task, completed=num_codemods)
return json.load(codetf)

Expand Down

0 comments on commit 45e8ed5

Please sign in to comment.