Running a task that has "&&" in it doesn't work. #85
-
Hello. I'm trying to add a task that is a couple of commands chain together. [tool.poe.tasks]
test = "mypy . && pytest ." and run it, I get the following output:
Is there a way to make this work? It would be really useful if I can chain commands. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @adhamsalama, Absolutely there's a way to make this work. Firstly the issue you're facing it that the default type of task (called a "cmd" task) is a single subprocess without a shell. If you want to invoke the task using a shell (and thereby get support for POSIX shell syntax like For example the following should do what you want: [tool.poe.tasks]
test.shell = "mypy . && pytest ." Note that shell tasks depend on the relevant shell executable on the host system. This means they're slightly less portable than other task types, because windows users might not have bash installed. However it's also possible to achieve this using a sequence task, which is defined in terms of other tasks. For example you might instead want to do something like: [tool.poe.tasks]
types = "mypy ."
test = "pytest ."
check.sequence = ["types", "test"] This will give you three separate tasks, the Finally although it's maybe overkill for such a trivial example you can also compose tasks as dependency graphs. The simplest example being making the [tool.poe.tasks]
types = "mypy ."
test = { cmd = "pytest .", deps = ["types"] } It's all in the read me ;) |
Beta Was this translation helpful? Give feedback.
Hi @adhamsalama,
Absolutely there's a way to make this work. Firstly the issue you're facing it that the default type of task (called a "cmd" task) is a single subprocess without a shell. If you want to invoke the task using a shell (and thereby get support for POSIX shell syntax like
&&
) then you need a shell task which by default will use bash.For example the following should do what you want:
Note that shell tasks depend on the relevant shell executable on the host system. This means they're slightly less portable than other task types, because windows users might not have bash installed.
However it's also possible to achieve this usi…