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

default: this.appname in custom generator, can't get right current directory name #240

Open
HJM515 opened this issue Sep 26, 2020 · 0 comments

Comments

@HJM515
Copy link

HJM515 commented Sep 26, 2020

yeoman-generator version: 4.12.0
When the current directory name is like my-project, the appname is my project. This is not in my mind. The current directory is empty, has not bower.json or package.json.
You know, if use generator to get package.json, the name like "my project" is not valid.
If the current directory name is like my_project, I can get right appname.
Can we get the right directory name? or give a reason to help me understand what happen?

ENV

yeoman-generator: 4.12.0
node: 12.18.4
yo: 3.1.1

Code of custom generator

const Generator = require("yeoman-generator");
module.exports = class extends Generator {
  prompting() {
    return this.prompt([
      {
        type: "input",
        name: "name",
        message: "Your project name",
        default: this.appname,
      },
    ]).then((answers) => {
      this.answers = answers;
    });
  }
  writing() {
    const tmpl = this.templatePath("package.json");
    const output = this.destinationPath("package.json");
    const context = this.answers;
    this.fs.copyTpl(tmpl, output, context);
  }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant