Skip to content
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

Add possibility to set program.on("close") event or event for all commands #1158

Closed
prokopsimek opened this issue Jan 31, 2020 · 6 comments
Closed

Comments

@prokopsimek
Copy link
Contributor

I continue in our discussion in closed PR here: #996

My intent is to display a notification about the new package version in CLI at the end of each run of any command.

I have prepared my intended implementation here: DXHeroes/dx-scanner#232 (review) (the PR is invalid)

@shadowspawn
Copy link
Collaborator

There isn't currently a generic event after any command runs.

How about checking for the notification after calling parse? It seems this might have a similar outcome that the notification is displayed if the parse did not detect errors or display the help, but I may be missing some of your workflow cases.

    await cmder.parseAsync(process.argv);
    this.notifyUpdate);

@prokopsimek
Copy link
Contributor Author

Thanks, I'll try that and give feedback.

@prokopsimek
Copy link
Contributor Author

prokopsimek commented Feb 2, 2020

@shadowspawn Wow, it works! 🎉
It works if I run a subcommand (e.g. ./bin/run practices) but doesn't work if I run a root command that displays help (just ./bin/run). The .help function terminates with process.exit(0)?

   if (!process.argv.slice(2).length) {
      cmder.help();
    }

ref.: https://github.com/DXHeroes/dx-scanner/pull/231/files#diff-f41e9d04a45c83f3b6f6e630f10117feR77-R79

@shadowspawn
Copy link
Collaborator

.outputHelp() displays the help without calling exit.

@shadowspawn
Copy link
Collaborator

This was a specific case which might have been resolved, and no recent activity. Closing in favour of #1197.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

@prokopsimek
Copy link
Contributor Author

@shadowspawn Thanks for your help! It was a great experience. 🙂 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants