Search code examples
yeomanboweryeoman-generator

In a yeoman generator, how can I define and install dependencies to be installed with bower?


I'm building a yeoman generator.

When the generator gets called, I'd like javascript libraries to be installed. I could do this manually by running 'bower' for every dependancy after the scaffold is up. But I'd prefer to have this step automated.


Solution

  • I see two approaches:

    Either way, when the generator is run, bowerInstall() will do its magic. generator-gulp-webapp installDependencies. There's an example for wiredep in there, too.


    You just need to call generator.bowerInstall() to launch the installation. Yeoman will ensure the bower install command is only run once even if it is called multiple time by multiple generators.

    ...

    Call generator.installDependencies() to run both npm and bower.

    http://yeoman.io/authoring/dependencies.html