OfficeDev / generator-office

Yeoman generator for building Microsoft Office related projects.
https://www.npmjs.com/package/generator-office
MIT License
838 stars 208 forks source link

Generator seems to hang waiting for user to hit Enter to finish #10

Closed jasonjoh closed 8 years ago

jasonjoh commented 9 years ago

Using generator on Windows 10 in the following manner:

yo office
? Project name (display name): yotest2
? Root folder of project? Default to current directory
 (C:\Users\jasonjoh\Source\Repos\mail-addins\yotest2), or specify relative path
  from current (src / public):
? Office project type: Mail Add-in (read & compose forms)
? Technology to use: HTML, CSS & JavaScript

After the generator does its work, and the final line is output:

microsoft.office.js#2b215a298b bower_components\microsoft.office.js

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.

martellaj commented 9 years ago

+1 confirmed.

andrewconnell commented 9 years ago

Confirmed... investigated but not sure what's causing it. Still under investigation...

waldekmastykarz commented 9 years ago

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.

waldekmastykarz commented 9 years ago

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.

andrewconnell commented 9 years ago

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.

jasonjoh commented 9 years ago

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.

jasonjoh commented 9 years ago

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?

jthake commented 9 years ago

Gonna sit with @andrewconnell and work through this one...

andrewconnell commented 9 years ago

@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.

jasonjoh commented 9 years ago

Ah ok, I figured it must be something like that. Well that blows my easy fix :)

jasonjoh commented 8 years ago

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?

andrewconnell commented 8 years ago

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

jasonjoh commented 8 years ago

On #1, yes, you leave it as an option in the top-level generator, just remove the prompt.