Skipping a Task with an active prompt
See original GitHub issueIn one of my use cases, I would like the user to press a key if they want to interrupt the current task, otherwise continue on.
For example, I have an enquirer prompt that is something like the following Press any key to abort, otherwise continuing in 10 seconds...
However, when I skip the task while the prompt is active, the task get skipped but the prompt is still active in the background.
If I try to cancel the prompt, I always get hit with an error so that too exits the pipeline
enquirer.on("prompt", async prompt => {
await delay(10000);
prompt.cancel();
});
Lastly, if I try to skip the prompt with the built in skip function (which accepts a Promise<boolean>
type), the prompt disappears into the background but is still active until it gets skipped
const status = await task.prompt({
name: "continue",
type: "input",
message: `Press any key to abort, continuing in 10 seconds otherwise`,
skip: async () => {
await delay(10000);
return true;
}
});
What would be the appropriate approach for this pattern? I can make a contribution for it as well
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (23 by maintainers)
This should work for examples, no need to build them if I get you correctly.
If you install all the dependencies as you did to build the project, I think linking should work but enquirer is not installed as production dependency. So I am not sure what went wrong.
The easier way of doing this is running the docker-compose stack and linking the package to your project via npm. Since it will recompile on changes.
Yeah I agree on that part as well.
If ctrl-c -> error via skip or cancelledprompt or such -> no error, just carry on