From e71f92f9ad3bfd2039a5e6a5cf5393624fb583f0 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Thu, 14 Mar 2024 08:16:49 +0100 Subject: [PATCH] add docs --- docs/advanced/advanced_tasks.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/advanced/advanced_tasks.md b/docs/advanced/advanced_tasks.md index ef1bdb95e0..152f4b4ade 100644 --- a/docs/advanced/advanced_tasks.md +++ b/docs/advanced/advanced_tasks.md @@ -128,6 +128,32 @@ This will add the following line to `pixi.toml`: bar = { cmd = "python bar.py", cwd = "scripts" } ``` +## Caching + +When you specify `inputs` and/or `outputs` to a task, pixi will cache the result of the task. + +For the cache, pixi checks that the following are true: + +- No package in the environment has changed. +- The selected inputs and outputs are the same as the last time the task was run. +- The command is the same as the last time the task was run. + +If all of these conditions are met, pixi will not run the task again and instead use the existing result. + +Inputs and outputs can be specified as globs, which will be expanded to all matching files. + +```toml title="pixi.toml" +[tasks] +# This task will only run if the `main.py` file has changed. +run = { cmd = "python main.py", inputs = ["main.py"] } + +# This task will remember the result of the `curl` command and not run it again if the file `data.csv` already exists. +download_data = { cmd = "curl -o data.csv https://example.com/data.csv", outputs = ["data.csv"] } + +# This task will only run if the `src` directory has changed and will remember the result of the `make` command. +build = { cmd = "make", inputs = ["src/*.cpp", "include/*.hpp"], outputs = ["build/app.exe"] } +``` + ## Our task runner: deno_task_shell To support the different OS's (Windows, OSX and Linux), pixi integrates a shell that can run on all of them.