Closed jasonjoh closed 8 years ago
+1 confirmed.
Confirmed... investigated but not sure what's causing it. Still under investigation...
For what it's worth: I've found that when you run yo office
the generator waits at the end to press Enter as you guys mentioned, but if you call it with a specific add-in type, ie yo office:taskpane
it finishes just as expected.
Digging a bit further I found out that it's the clients
question that's causing the stop. If you pass it as one of the options, ie. yo office --clients Word
the generator finishes as expected without the need to press Enter at the end.
I wish that was the case... it was doing this before we added the question about which client(s) you wanted.
Need to look into it more. I actually see this with multiple command line tools based on Node... not just Yeoman.
It seems to be related to the interactions of prompts between the main generator and the subgenerator. I was playing with extending the mail subgenerator and added another prompt in the sub (./mail/index.js). The stop disappeared. However my prompt was a checkbox prompt, and I couldn't interact with it. I moved it to the main generator (./app.index.js) and I could then interact with it. But the stop reappeared!
So, not an answer, but maybe a clue.
Ok, more info: If you remove the askFor
function altogether from ./mail/index.js, the stop disappears. (You have to add the line this.genConfig = extend(this.genConfig, this.options);
to the constructor though if you do this!) My guess is that because the prompts in that function are redundant with the prompts in the askFor
in ./app/index.js, we're basically calling this.prompt
with all disabled prompts (from the when
clause), and maybe it requires you to hit enter?
So the question is why do we have another askFor
in ./mail/index.js that repeats the same prompts from ./app/index.js? Is there a way to call the mail one directly without going through app?
Gonna sit with @andrewconnell and work through this one...
@jasonjoh The reason we dupe the askFor
question is if someone runs the subgenerator directly. You can call the default subgenerator app which simply acts as a router of sorts by using $ yo office
. Based on what you question answers are in the prompts, it calls another subgenerator. For instance all these are valid:
$ yo office:mail
$ yo office:content
$ yo office:taskpane
So you can't just remove the askFor
from the subgenerators... it will break running a subgenerator because there will be no prompts.
Ah ok, I figured it must be something like that. Well that blows my easy fix :)
So a couple of updates on this one.
First: you don't need to duplicate the prompts. You can just keep the prompt in the subgenerator and let it do the prompting. The app
generator should only ask questions that apply across all of the subgenerators.
Second: the hang may be related to https://github.com/SBoudrias/Inquirer.js/issues/266, which in itself is apparently a bug in Node.js on Windows. This explains the behavior I reported above with the new prompt (couldn't interact with a checkbox prompt). There's a state that Inquirer can get into where it pauses waiting for an Enter. @andrewconnell, have you seen this on any non-Windows machines?
RE #1 – can you still call the generator with arguments to bypass the questions? Will they still get picked up by the sub generators? That’s the primary reason we added them to the app “top-level” generator
RE #2 – interesting… but I don’t think it’s Windows related. I see it from time to time on OS X and that’s the only place I use the generator
On #1, yes, you leave it as an option in the top-level generator, just remove the prompt.
Using generator on Windows 10 in the following manner:
After the generator does its work, and the final line is output:
The generator seems to hang, with the cursor just flashing. If you press Enter, it will exit.
Ideally the need to hit Enter can be removed, but if it can't, the tool should tell the user they need to hit Enter to exit.