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 support for callbacks #18

Open
brikis98 opened this issue Sep 16, 2016 · 2 comments
Open

Add support for callbacks #18

brikis98 opened this issue Sep 16, 2016 · 2 comments
Labels
enhancement New feature or request

Comments

@brikis98
Copy link
Member

To make boilerplate even more flexible and powerful, it would be great to support "callbacks" where you can provide arbitrary code to execute at specific times. For example, there could be a start callback that gets called just after Boilerplate gathers all variables but before it starts generating; a file callback called for each file and folder Boilerplate processes; and an end callback called after project generation is finished. The callbacks could be defined as simple shell commands in boilerplate.yml:

variables:
  - name: foo
  - name: bar

callbacks:
  start: echo "Boilerplate is generating files to $2 from templates in $1"
  file: echo "Boilerplate is processing file $1"
  end: echo "Boilerplate finished generating files in $2 from templates in $1"
@josh-padnick
Copy link
Contributor

Can you give an example use case of this?

@brikis98
Copy link
Member Author

Sure. Let's say you're using boilerplate to generate a skeleton for a react.js project. Actually, here's an example of just such a template: https://github.com/Granze/react-starterify

You could package that template as a boilerplate template and use the callbacks as follows:

  • start: Look on GitHub and see if there is a newer version of the template available. If there is, prompt the user to download the latest version.
  • file: when the package.json file is being processed, run the npm update command to fetch the latest version of each Node.js package (this may be a way to solve Add support for "lookup latest release in GitHub" #8, BTW).
  • end: run npm install to install all those dependencies and npm run watch to immediately put you into live reload development mode as soon as the project is finished generating.

@infraredgirl infraredgirl added enhancement New feature or request and removed T: Enhancement labels Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants