Tasks with multiple commands

Hi there,

Is it possible to have multiple TaskProcessActions within a Task? Or, is it possible to instead use a script instead of a single command?

Would this be something possible with postActions? I just can’t find a way to define that in code :frowning:

Hello Brendan,

This is not currently possible directly; Your best option here would be to combine your multiple process invocations into a shell script (which can be invoked as a single task). If the multiple actions being run are dynamic and are not known beforehand, you would be able to write a shell script out to, for example, a temporary directory.

The postActions are not intended to be manipulated by extensions. They are defined by the end user in Nova’s task pipeline UI as additional actions that can be done in addition to an extension’s contributed actions. As such, they are not exposed to the extension API.

Thanks @Logan ! Would you happen to have an example of how it would work with a shell script, not sure how the file reference would work :frowning:

@Logan also will support for this be coming in the future? I feel like this is an extremely powerful feature to have. I know you’ve said they’re not currently intended to be manipulate by extensions but I do feel that having them would provide a lot of value. An example would be pre-running a linter/formatter prior a build step.

There’s a couple of ways you could potentially do this.

The most simple, perhaps, would be to write out your commands as a shell script into a temporary directory. You can do this with a combination of the nova.fs.open(), nova.fs.tempdir, and nova.path.join() APIs to open a file handle to a specific temporary filename within a temporary directory (see here). You’d also probably want to make sure that the shell script is made executable, by invoking nova.fs.chmod() with a bitmask capable of execution, such as 755.

As for the shell script itself, its contents would be the commands you wish to invoke, one after the other. You could also use another scripting language, such as Python, if you knew the end-user would have it installed depending on the tooling your extension requires.