diff options
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -17,6 +17,7 @@ - [String Formatting](#string-formatting) - [Always Use Variables](#always-use-variables) - [Recursive Variables](#recursive-variables) + - [Working directory](#working-directory) - [Using Taskipy Without Poetry](#using-taskipy-without-poetry) - [Installing With PIP](#installing-with-pip) - [Running Tasks](#running-tasks-1) @@ -282,6 +283,28 @@ echo = "echo {package_dir}" In this example, we could run `task echo` and we would then see `src/package`. +### Working directory + +By default, all tasks run from the directory where they are called. This makes possible to change folder and run flexible tasks depending on the current folder. + +However, some tasks may need to always run in the same working directory, regardless from where they are called. + +If you want tasks to always run relative to a specific path, you can use the `"cwd"` setting to define a current working directory of the task relative to the root of the project (where the `pyproject.toml` file is): + +```toml +[tool.taskipy.tasks] +echo = { cmd = "python -c \"import os; print(os.getcwd())\"" , cwd = "."} +``` + +In this example, running `task echo` will print the directory path of the file `pyproject.toml` regardless of the folder that you call this task. + +If you want to define `cwd` globally (setting all tasks to always run from the same working directory) you just need to declare that under taskipy's **settings** table: + +```toml +[tool.taskipy.settings] +cwd = "." +``` + ### Using Taskipy Without Poetry Taskipy was created with poetry projects in mind, but actually only requires a valid `pyproject.toml` file in your project's directory. As a result, you can use it even without poetry: |