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

Adding before/after lifecycle hooks #43

Open
shaine opened this issue Oct 8, 2016 · 2 comments
Open

Adding before/after lifecycle hooks #43

shaine opened this issue Oct 8, 2016 · 2 comments

Comments

@shaine
Copy link

shaine commented Oct 8, 2016

Loving this lib, finding it extremely useful in our project. As we accrue more and more scripts, we're finding that most scripts share some basic startup/shutdown behaviors, which (in line with the seeming intent of this lib) might be better served as some sort of lifecycle hooks rather than repeated boilerplate. As a trivial example, a big team might be interested in displaying a warning if a project's npm modules aren't up-to-date before running any script.

Following the convention-over-configuration style found here, scripty could look for ./scripts/hooks/before and ./scripts/hooks/after.

This seems appropriate to add to the lib to me, but I could also understand an argument that this is strictly a userland concern. Thoughts?

@searls
Copy link
Member

searls commented Oct 12, 2016

I think this seems reasonable, but I'm not sure how/whether the lib needs to implement it, since your various scripts themselves could implement the same thing (depending on your scripting language you could make it invisible from each individual script, too).

That said, if you produced a simple PR that implemented an intelligent hooks/ directory (which got quashed gracefully in the presence of a conflicting package script named hooks:before), then I think that'd be cool. I imagine you'd want before-each, before-all, after-each, and after-all.

@texastoland
Copy link
Contributor

texastoland commented Jul 27, 2018

👍🏽 I like this. What would be a use case for the *each variant? I think the best way to implement this would in options.

"scripty": {
  "prerun": "hooks:before",
  "postrun": "hooks:after"
}

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

No branches or pull requests

3 participants