trunk icon indicating copy to clipboard operation
trunk copied to clipboard

Expose watch status to hooks

Open Madoshakalaka opened this issue 1 year ago • 3 comments
trafficstars

I wish trunk emits "build success/error" messages during a watch task as I'm making a statusline plugin for trunk in neovim.

Madoshakalaka avatar Jul 05 '24 19:07 Madoshakalaka

When using trunk serve, you can already have that in the browser. So there's a websocket which emits that state. I think you should be able to use the same.

ctron avatar Jul 09 '24 06:07 ctron

unfortunately I can't use that. I use trunk in an SSR project and builds the SSR server after the frontend. I run trunk watch and touch .build_trigger in one of the hooks, which triggers the SSR server to build. The problem is, sometimes the frontend fails to build and I can't immediately know why without switching tabs/navigating (especially when rust-analyzer uses every feature flag from the whole workspace which differs from those used in frontend building so I can't detect it in the editor)

Madoshakalaka avatar Jul 09 '24 07:07 Madoshakalaka

Ah, I see. Yes that makes sense. And it might be good idea to have that.

Just thinking about possible ways to transport that information, what about using the same serialization (JSON) and writing that to some file? (dist folder, target folder?) and then providing an env-var for the hooks pointing to that file. That file might exist in any way, having an "ok" status by default.

ctron avatar Jul 09 '24 08:07 ctron