-
Notifications
You must be signed in to change notification settings - Fork 29.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre & Post callbacks per task for Tasks Runner #29855
Comments
Nice idea. With 1.14 we will have task API (without this feature) but now that API for tasks is there in general I think adding these pre / post hooks should not be too complicated. |
Do you have some progress on this feature? Thanks! |
None. However we have planned for this milestone to allow extension to participate in task execution. But no concrete API yet so I don't know if the new API will support this use case. |
Oh...1 year... Do you have any idea how could we kill running tasks without annoying warning/popup? We use this code https://github.com/platformio/platformio-vscode-ide/blob/develop/src/main.js#L215 Thanks! |
Currently not since the command use designed to work with user interaction. However there is now proposed API that lets you start and terminate tasks. May be that would help in your scenario. It has events for task start and task terminate as well. |
Do you have some ETA when I can test it? |
@ivankravets the API got added to vscode.proposed.d.ts for this milestone. No concrete deadline for the final API yet. |
@dbaeumer any updates on this? |
The new API is still in proposed state since I in cooperated feedback and changed some signatures. |
@dbaeumer thanks for quick update :) |
If you have feedback now is the time to provide it :-) |
Do we have the only proposed API or also the implementation for it? |
The proposed API has an implementation. But you can't use proposed API from a deployed extension. You can only use it during dev time. |
I understand, can I try it locally? I just want to be sure that this new API will help us to resolve our issue platformio/platformio-vscode-ide#49 Could you give me some hints how can I try it? Thanks! |
@jrieken do we have a wiki / issue explaining how to test proposed API? |
Something small from the release doc: https://code.visualstudio.com/updates/v1_21#_proposed-extension-apis |
@dbaeumer sorry for the delay. I've just finally found a time to test new API. It seems that it works. However, I can't make our workflow working with the new API. The idea is simple - if we have running Serial Monitor (tasks, NOT task, they can have different monitor args), we should close it before specific tasks (firmware upload, etc). So, I created a simple draft to reproduce this workflow: Code let restoreTask = null;
vscode.workspace.onDidStartTask(((e) => {
console.log('onDidStartTask: ' + e.execution.task.name);
if (e.execution.task.name === 'Monitor') {
return;
}
vscode.workspace.taskExecutions.forEach((e) => {
if (e.task.name === 'Monitor') {
restoreTask = e.task;
e.terminate();
}
});
}));
vscode.workspace.onDidEndTask(((e) => {
console.log('onDidEndTask: ' + e.execution.task.name);
if (e.execution.task.name === 'Monitor' || !restoreTask) {
return;
}
console.log(restoreTask);
vscode.workspace.executeTask(restoreTask);
restoreTask = null;
})); Output
SummaryAs you can see, everything works good excluding the last step with |
@dbaeumer do you plan to move this API to stable branch in this May release? This is the last blocking issue for us. |
I already moved it to stable for the May release. @ivankravets can you provide me with a simple GitHub respository I can clone that demos your problem. Then I will look into fixing it for May. |
It's very easy to reproduce, you don't need to have a separate repo. Try to assign "execution.task" instance from So, later in |
See example above, it should be "previous" task, not current.
|
I doubt that this makes a difference but I give it a try |
@dbaeumer Could you show me your code? I've just tried the latest Insider build and it does not work for me even for the current task: vscode.workspace.onDidStartTask(((e) => {
console.log('onDidStartTask: ' + e.execution.task.name);
}));
vscode.workspace.onDidEndTask(((e) => {
console.log('onDidEndTask: ' + e.execution.task.name);
vscode.workspace.executeTask(e.execution.task);
})); Is my code correct? |
I see strange error in develop console. Already tried To be honest, I don't understand. How does half of new task API work and another doesn't? It seems that |
@ivankravets this is the code I used:
|
Ok, I've finally found a problem
|
The vscode.workspace.executeTask is still proposed and will be removed next milestone. The API started in vscode.workspace since we got more task related API we create a separate namespace vscode.tasks for it. So all task API will be available in the tasks namespace in the future. Internally they forward to the same implementation. BTW I fixed #50858. Will be available tomorrow in insider. |
@ivankravets i checked build Version 1.24.0-insider and there everything is correct on the vscode.tasks namespace. |
Finally, it works now!!! Thank you so much! 👍 🍺 😊 |
Copy from #20446 (comment)
Is possible to subscribe to
onDidTaskRun()
, where would be an ability to catch up some tasks and perform some operations? We havepre
andpost
callbacks in Atom Build for each task.Simple use case. User open @platformio Serial Monitor via integrated Terminal, we see it. He triggers "Upload" task, we temporary close opened Serial Port Monitors/Terminals, then uploading firmware. If a task fails with an error, we don't re-open Monitor. However, if the upload was successful, we re-open last Serial Port Monitor.
Thanks for the hints!
The text was updated successfully, but these errors were encountered: