Skip to content

Commit

Permalink
meson: Dump stdout and stderr when npm fails
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Sep 20, 2024
1 parent 6d9a5a4 commit b0b1ff2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 7 additions & 1 deletion agents/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def main(argv: list[str]):

try:
build(npm, inputs, output_js, priv_dir)
except subprocess.CalledProcessError as e:
print(e, file=sys.stderr)
print("Output:\n\t| " + "\n\t| ".join(e.output.strip().split("\n")), file=sys.stderr)
sys.exit(1)
except Exception as e:
print(e, file=sys.stderr)
sys.exit(1)
Expand All @@ -35,7 +39,9 @@ def build(npm: Path, inputs: list[Path], output_js: Path, priv_dir: Path):

shutil.copy(srcfile, dstfile)

subprocess.run([npm, "install"], capture_output=True, cwd=priv_dir, check=True)
subprocess.run(
[npm, "install"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding="utf-8", cwd=priv_dir, check=True
)

frida_compile = priv_dir / "node_modules" / ".bin" / f"frida-compile{script_suffix()}"
subprocess.run([frida_compile, entrypoint, "-c", "-o", output_js], cwd=priv_dir, check=True)
Expand Down
12 changes: 11 additions & 1 deletion apps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def main(argv: list[str]):

try:
build(npm, inputs, output_zip, priv_dir)
except subprocess.CalledProcessError as e:
print(e, file=sys.stderr)
print("Output:\n\t| " + "\n\t| ".join(e.output.strip().split("\n")), file=sys.stderr)
sys.exit(1)
except Exception as e:
print(e, file=sys.stderr)
sys.exit(1)
Expand All @@ -34,7 +38,13 @@ def build(npm: Path, inputs: list[Path], output_zip: Path, priv_dir: Path):

shutil.copy(srcfile, dstfile)

npm_opts = {"cwd": priv_dir, "capture_output": True, "check": True}
npm_opts = {
"cwd": priv_dir,
"stdout": subprocess.PIPE,
"stderr": subprocess.STDOUT,
"encoding": "utf-8",
"check": True,
}
subprocess.run([npm, "install"], **npm_opts)
subprocess.run([npm, "run", "build"], **npm_opts)

Expand Down

0 comments on commit b0b1ff2

Please sign in to comment.