Kos
Kos

Reputation: 72241

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"]
            ...
        }

Upvotes: 4

Views: 178

Answers (1)

Yury Tarabanko
Yury Tarabanko

Reputation: 45121

Following this issue you could run generators by file path

yo ./generators/path/to/local/file.js

Upvotes: 2

Related Questions