-
-
Notifications
You must be signed in to change notification settings - Fork 298
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
Empty generators #1276
Comments
This issue is stale because it has been open with no activity. Remove stale label or comment or this will be closed |
Please reopen this issue. |
@ozum can you want to provide a PR? |
I would like to. Since I'm not familiar with the codebase, it seems enough to remove the condition below. Is it OK, or are there any dependent code? generator/index.js line 935 contains: if (validMethods.length === 0 && this._prompts.length === 0) {
throw new Error(
'This Generator is empty. Add at least one method for it to run.'
);
} |
A generator without tasks is an error, unless you are doing advanced use like you said. |
Hmm, Something like below? this.option('allow-empty-generator', {
type: Boolean,
description: 'Allows generators without tasks.',
default: false
});
// ...
if (!this.options.allowEmptyGenerator && validMethods.length === 0 && this._prompts.length === 0) {
throw new Error(
'This Generator is empty. Add at least one method for it to run.'
);
} |
The option should not be exposed to users, so no So
And add tests. |
Currently, I can't migrate to Yeoman 5. Is there a way for v4? |
It's not worth, you can try to create a empty function on the object in the parent constructor: this.notEmptyGenerator = function() {}; Object.assign(this, {function notEmptyGenerator()}); There are others alternatives if those don't work. |
Thanks for the suggestion @mshima. |
Similar to #761, I need to run an empty generator. My use case is different though.
I'm developing an abstract generator. This base generator has a queued method called
generateDbFiles
, which is executed for each child generator. This method uses the_render()
methods provided by the child generators.So, child generators should provide a
_render()
method and some template files. If they don't want to change default behavior no more methods are necessary. This results inThis Generator is empty. Add at least one method for it to run.
error.Could you please allow an empty generator? Otherwise, all child generators need to supply an empty stub method.
Many thanks,
The text was updated successfully, but these errors were encountered: