From 43fb80586043da50f81e2e935afb2fbc6f55ec24 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Thu, 19 Mar 2026 20:29:35 +0100 Subject: Zen disk benchmark utility (#868) This PR adds a `zen bench disk` subcommand to help with gathering user performance metrics It also contains a fix for `xmake precommit`, the task now probes to find the most appropriate way to launch pre-commit --- xmake.lua | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'xmake.lua') diff --git a/xmake.lua b/xmake.lua index a84253082..5b4b3958c 100644 --- a/xmake.lua +++ b/xmake.lua @@ -571,7 +571,32 @@ task("precommit") description = "Run required pre-commit steps (clang-format, etc)", } on_run(function () - print(os.exec("python -m pre_commit run --all-files")) + -- pre-commit can be installed as a standalone executable (e.g. via pipx, + -- Homebrew, or system packages) or as a Python module. We prefer the + -- standalone binary because it works regardless of which Python name the + -- system exposes. If it isn't in PATH we fall back to invoking it as a + -- module, trying "python" first since some systems only have that, and + -- "python3" otherwise. + local cmd + try { + function() + os.exec("pre-commit --version") + cmd = "pre-commit run --all-files" + end, + catch { function() end } + } + if not cmd then + local python = "python3" + try { + function() + os.exec("python --version") + python = "python" + end, + catch { function() end } + } + cmd = python .. " -m pre_commit run --all-files" + end + print(os.exec(cmd)) end) task("sln") -- cgit v1.2.3