Closed RafaelGorski closed 8 years ago
Thanks for reporting. Will check it out asap.
I can reproduce, but no idea why this is causing an error. When using generator-nm, which uses this.async() as well, it works like a charm.
@SBoudrias sorry to bother :), but any idea?
Anyway we can get a trace?
@SBoudrias No problem
TypeError: this.async is not a function
at Object.module.exports.prompts.when (/Users/sam/.nvm/versions/node/v4.2.1/lib/node_modules/generator-generator/node_modules/inquirer-npm-name/lib/index.js:20:23)
at /Users/sam/Projects/opensource/vscode-yo/out/yo/adapter.js:37:48
adapter.js:37:48 is refering to adapter.ts:48.
What is happening is that generator-generator
is asking for a generator name, when the user provides a name, it checks if the name exists on npm in inquirer-npm-name and it is failing in the when
clause here.
I wasn't aware it was possible to write the when
clauses async. So apart from the context not being bound correctly, I probably have to rewrite the line adapter.ts:48 differently.
@SamVerschueren ah yes, you're correct. Most Inquirer functions can be asynchronous. We're using run-aync to handle all of them. You might want to reuse that library too so it takes exactly the same signature.
@SBoudrias thanks! By using run-async
, I am able to make it work :).
Can you elaborate which properties of this list can be async? The documentation isn't very clear about it. My best guess are these
choices
validate
filter
when
But maybe default
and message
as well?
@RafaelGorski Should be fixed in v0.8.1
.
All of them can be async
Even the type
and the name
for example?
default, choices (if defined as functions), validate, filter and when functions can be called asynchronously using this.async(). You just have to pass the value you'd normally return to the callback option.
@SamVerschueren @SBoudrias you rock!!!! cheers //Rafael
@SBoudrias sorry, missed that. Thanks for quoting and for your time!
@RafaelGorski you're welcome :)
@SamVerschueren no worry, always happy to help.
Hi @SamVerschueren ,
First, great initiative to wrap yo inside the vscode! I got a error when I use it, I will try to explain the scenario.
When I try to use generator-generator from vscode the following error:
Steps: 1) yo
2) generator
3) <enter, confirming the suggestion>
4) error presented: Error this.async is not a function
Using the normal yo works fine:
Versions: npm -v --> 3.3.12 node -v --> v5.3.0