docs: {pre, post}Hook under Usage section (#64)

* docs: `{pre, post}Hook` under `Usage` section

* sequence

---------

Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
This commit is contained in:
Shivaraj B H 2024-05-07 12:05:45 +05:30 committed by GitHub
parent ee8cd505f0
commit 32c069e7ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -74,6 +74,32 @@ devShells = {
You can enter your devShell by running `nix develop` and run `watch-server` to run your processes.
### preHook
If you'd like to run certain commands before starting the processes, you can add them to `preHook`:
```nix
process-compose.watch-server = {
preHook = ''
# Cleanup on EXIT, this runs irrespective of exit-code of process-compose
trap "rm -rf ./data" EXIT
export USER=foo
'';
};
```
### postHook
Or if you'd like to run certain commands upon successful execution of `process-compose`, i.e exits with `exit-code: 0`, then add them to `postHook`:
```nix
process-compose.watch-server = {
postHook = ''
cat foo.txt
'';
};
```
## Module API
Our submodule mirrors the [process-compose YAML schema](https://github.com/F1bonacc1/process-compose/blob/main/process-compose.yaml). A few things to remember: