Skip to content
addyosmani edited this page Apr 17, 2013 · 3 revisions

Yo currently pulls in a specific, stable SHA of the generators repo which is used during installation.If you wish to update your local clone of Yo to use a more recent SHA of whats in master on the Generators repo, this can be done in the main package.json file under the dependencies section.

If you wish to develop on the generators code base, and debug locally, a common way to do so is to rely on npm link

  1. git clone the generators repo locally
  2. cd into that repository and run npm link. It'll install required dependencies and install the package globally, using a symbolic link to your local version.
  3. If you want to install sub generators, you need to do so in the context of yeoman-generator package linked earlier. Cd into the sub generators package you have cloned locally and run npm link.
  4. We now have everything linked and known on the system, we now need to link the subgenerator repo into the parent one, yeoman-generator cloned and linked in step 1 & 2.

Synopsis

# clone and link generators package
$ mkdir -p ~/dev && cd ~/dev
$ git clone [email protected]:yeoman/generators.git
$ cd generators
$ npm link

# clone and link generator repo
$ cd ~/dev
$ git clone [email protected]:yeoman/generator-webapp.git
$ cd generator-webapp && npm link
$ git clone [email protected]:yeoman/generator-mocha.git
$ cd generator-mocha && npm link
$ cd ~/dev/generator-webapp && npm link

# cd back into generators package, link subrepos
$ cd ~/dev/generators
$ npm link generator-webapp
$ npm link generator-mocha

# test it out
$ mkdir ~/test/yeoman
$ cd ~/test/yeoman
$ mkdir webapp && cd webapp
$ yo --help
# should list both webapp and mocha namespace

$ yo webapp
# should behave as expected

You now have your system setup for testing and debugging locally. Note that you can also link or install the subgenerators locally to your project (in the example above, ~/test/yeoman/webapp).

Note that generators relies on the yeoman-generator package to be able to access the API defined in generators.Base, thus they'll use the package install locally which differ from your linked version.

If you wish to do so, you can link yeoman-generator in each sub generator package to make them point to your local and linked version.

Just try to avoid to link the sub generator from within yeoman-generator, or you might end up in a symbolic link loop scenario.

To enable the sub generators discovery, simply rely on locally installed or linked package in your test project.

Clone this wiki locally