lefthook icon indicating copy to clipboard operation
lefthook copied to clipboard

add support for background jobs of indefinite length

Open masukomi opened this issue 1 year ago • 2 comments

:zap: Summary

support background jobs where you don't care how long it takes or if it finishes successfully

Value

Sometimes a git interaction should kick off a process, but you you don't want to have to wait for that process to finish and you don't really care if it finishes successfully.

admittedly silly example:

lolcommits allows you to snap a picture whenever you make a commit. It also allows you to generate N seconds worth of animated gif. If you capture 3 seconds worth of video on every commit, then you'll have to wait an additional 3 seconds for lefthook to finish. Yes, this can be worked around via a wrapper script that bash forks but that's not the point. I'm just trying to give you a simple example and show why it'd be nice to not have to work around the lack of background job support.

Behavior and configuration changes

  • add support for a background: true key and documentation that says that the output of backgrounded tasks will not be considered.
  • indicate that the task has been started like any other
  • fork the process so that the normal lefthook invocation can exit and you can get on with whatever you were doing while the background process runs.

masukomi avatar Jun 27 '23 14:06 masukomi

Sounds good! Thank you for the feature request. Currently I don't have enough resources (time and power) to implement this feature, but if you want to try Go and contribute to the open source project - I'll be glad to help!

mrexox avatar Jun 27 '23 15:06 mrexox

By the way, have you considered using & at the end of the command?

long-running:
  commands:
    loong:
      run: sleep 1000 &
lefthook run long-running
╭────────────────────────────────────────╮
│ 🥊 lefthook v1.6.7  hook: long-running │
╰────────────────────────────────────────╯
┃  loong ❯



  ────────────────────────────────────
summary: (done in 0.00 seconds)
✔️   loong

mrexox avatar Mar 15 '24 15:03 mrexox