SamVerschueren / vscode-yo

Yeoman plugin for VS Code
MIT License
87 stars 15 forks source link

this.appname as default does not work the first time #32

Closed SamVerschueren closed 8 years ago

SamVerschueren commented 8 years ago

generator-nm uses this.appname as default application name. The first time the generator is executed, the app name is empty. When quitting the generator (by pressing escape) and running generator-nm again, the app name is correct.

The adapter is just getting the question here.

When I put a breakpoint here, the first question in the array is

{
    "default": "",
    "filter": x => _s.slugify(x),
    "description": "What do you want to name your module?",
    "name": "moduleName"
}

The second time I run the generator, the default value is correct.

{
    "default": "yo-test",
    "filter": x => _s.slugify(x),
    "description": "What do you want to name your module?",
    "name": "moduleName"
}

Any idea how this is possible? @sindresorhus @SBoudrias

SBoudrias commented 8 years ago

appname is defined here. It uses the names from bower/package.json or default to the folder name here https://github.com/yeoman/generator/blob/master/lib/base.js#L765

It's correct on the second run because there's probably a config file containing the name.

My guess is under your plugin, path.basename(this.destinationRoot()); doesn't return what we expect.

SamVerschueren commented 8 years ago

Alright, I found the problem. The first time the environment was created, the cwd path was not set correctly. So when debugging that https://github.com/yeoman/generator/blob/master/lib/base.js#L765 method, I found out that the destinationRoot() returned /. Thanks for pointing me in that direction!