From 4fdb7717317c6b9df7d290f0543f3abfa49f31ae Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 26 May 2020 15:17:10 -0700 Subject: [PATCH] Document how to run recipes after another recipe (#630) Add a section to the readme documenting how to shell out to Just at the end of a recipe, to simulate dependencies that run after a recipe, instead of before. This is certainly not as good as having an explicit syntax for this, but it's a common question so it would be good to document the current best workaround. --- README.adoc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.adoc b/README.adoc index 6ec5d5c..dd53fbb 100644 --- a/README.adoc +++ b/README.adoc @@ -613,6 +613,38 @@ search QUERY: lynx 'https://www.google.com/?q={{QUERY}}' ``` +=== Running recipes at the end of a recipe + +Dependencies of a recipes always run before a recipe starts. That is to say, the dependee always runs before the depender. + +You can call Just recursively to run a recipe after a recipe ends. Given the following justfile: + +```make +a: + echo 'A!' + +b: a + echo 'B!' + just c + +c: + echo 'C!' +``` + +…running 'b' prints: + +```sh +$ just b +echo 'A!' +A! +echo 'B!' +B! +echo 'C!' +C! +``` + +This has some limitations, since recipe `c` is run with an entirely new invocation of Just: Assignments will be recalculated, dependencies might run twice, and command line arguments will not be propagated to the child Just process. + === Writing Recipes in Other Languages Recipes that start with a `#!` are executed as scripts, so you can write recipes in other languages: