yeoman / generator

Rails-inspired generator system that provides scaffolding for your apps
http://yeoman.io
BSD 2-Clause "Simplified" License
1.22k stars 299 forks source link

Can't pass args via composeWith #1113

Closed haldunanil closed 5 years ago

haldunanil commented 5 years ago

I have a generator that has a name argument defined like so:

this.argument("name", {
  description: "The name(s) of the component(s) being generated",
  type: String,
  required: true
});

and I want to grab this.args and pass it straight down to my subgenerators via:

this.composeWith(
  require.resolve("generator-some-name/app", {
    name: this.args
  })
);

But nothing seems to be passed down to the subgenerator. The subgenerator also has a name argument defined the same way as above. Instead of the name key, I also tried args and arguments, but those don't work either. The current documentation only references what should be done prior to v1.0 but I can't seem to find any current examples that describe the correct way to pass args today. How can I accomplish this?

SBoudrias commented 5 years ago

Did you try changing name to a different name? I'm just wondering if maybe that would cause issue. You could also try replacing arguments with options. (not sure if it's a bug or not yet)

Also just in case

Note: If you need to pass arguments to a Generator based on a version of yeoman-generator older than 1.0, you can do that by providing an Array as the options.arguments key.

haldunanil commented 5 years ago

Oh lord I just noticed that my syntax was incorrect, I accidentally wrapped the options object inside the require.resolve function. 😳 My issue is fixed, closing issue