-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
In the pursuit of cleaner and more readable code, I want to leverage ES6 and leave callback hell, so I'm trying to get my .action() callbacks to become async methods, but I haven't yet found the optimal route.
I've tried wrapping the CB with co in two ways:
program.command('myCmd').action(program => co(function* (program) {...}).catch(err => console.log(err.stack)) );
andprogram.command('myCmd').action(co.wrap(function* (program) { .. }));
The problem with 1) is that the program parameter isn't passed
The problem with 2) is that errors are swallowed...
I'd really like to get this working as it yields much nicer code in my use case - involving a lot of http requests and also waiting for user input using the co-prompt library..
Is it a better option altogether perhaps to wrap program.Command.prototype.action somehow?
@tj I know this is a piece of cake for you - pls enlighten me!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels