Kos Kos - 2 years ago 228
Node.js Question

Can I have per-project Yeoman generators?

I have a Node project and I wanted to make a custom generator of components for this specific project.

I got it working by creating the generator as a separate package, but that's inconvenient - now I have to manage versioning of two packages instead of one, and rely on

yarn link
for development.

my-project/
src/
...
package.json
{
...
"devDependencies": {
"my-project-generator": "file:../my-project-generator"
]
}
my-project-generator/
generators/
...
package.json
{
...
"keywords": ["yeoman-generator"]
}


Is there a way to keep the generator inside the project itself? I tried this but
yo
didn't discover the generator.

my-project/
src/
...
generators/
...
package.json
{
"keywords": ["yeoman-generator"]
...
}

Answer Source

Following this issue you could run generators by file path

yo ./generators/path/to/local/file.js
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download