Skip to content
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

Commit files so I can re-generate the command #1092

Closed
theodorDiaconu opened this issue Sep 17, 2018 · 5 comments
Closed

Commit files so I can re-generate the command #1092

theodorDiaconu opened this issue Sep 17, 2018 · 5 comments
Labels

Comments

@theodorDiaconu
Copy link

Hello!

I would like to know if there is a way to have a sort-of recursive generation process.

I use autocomplete to specify the commands, because it's much easier than to have the person remember it. yo my-generator => Displays auto-completed list of commands

And I want after a command completes, to sort-of restart it until he selects 'quit' command.

The problem I'm facing is with file commits. It is done when the process ends. Is there any way to trigger the file comitting (and conflict resolution) manually ?

@mischah
Copy link
Member

mischah commented Sep 17, 2018

Hej,

I’m not sure that I understand what you trying to accomplish.

You can check the API docs to see how to use the conflicter: http://yeoman.io/generator/Conflicter.html#checkForCollision

For commiting files you can use something like https://github.com/steveukx/git-js

@theodorDiaconu
Copy link
Author

@mischah

Let's say I just have a prompting() function and that's it. That never returns, it's an infinite loop. However after I finish something, I want to run the file commit process (that actually commits mem-fs files). I did try yo.fs.commit() but does not work, and it's mentioned somewhere in the docs not to use it.

Let's talk a common language:

while(true) {
   // prompt for input
   // if value === quit, break
   // do something with value
   // commit, clear the cache of memfs
}

@mischah
Copy link
Member

mischah commented Sep 18, 2018

Ah. Got it.

Quoting the docs regarding the file system:

Generators expose all file methods on this.fs, which is an instance of mem-fs editor - make sure to check the module documentation for all available methods.

It is worth noting that although this.fs exposes commit, you should not call it in your generator. Yeoman calls this internally after the conflicts stage of the run loop.

It sounds that you have a reason for calling the commit() method.

Here are the docs regarding commit():
https://github.com/SBoudrias/mem-fs-editor#commitfilters-callback

You can pass a callback which is called when the files are written.

@theodorDiaconu
Copy link
Author

Yeoman calls this internally after the conflicts stage of the run loop.

I need to reach that stage somehow. Basically I would like for yeoman to proceed with the natural order of events, and before returning (quitting the process) hook-in a callback so I can get back into my loop.

@github-actions
Copy link
Contributor

This issue is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants