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

[Solved] JSON payload to generator #400

Open
rogrdat opened this issue Jul 2, 2022 · 1 comment
Open

[Solved] JSON payload to generator #400

rogrdat opened this issue Jul 2, 2022 · 1 comment

Comments

@rogrdat
Copy link

rogrdat commented Jul 2, 2022

I used to be able to execute this code (ver 4.x I think).., where the input to the generator was a JSON entity.., but have not been able to in more recent code. Could be something I'm missing.

async function run() {
   await execa('hygen', ['typeGen', 'new', `--args=${JSON.stringify(types[0])}`]).stdout?.pipe(process.stdout);
}
@rogrdat
Copy link
Author

rogrdat commented Jul 2, 2022

Solved the issue this way --

async function run() {
   await execa('hygen', ['typeGen', 'new',  JSON.stringify(types[0]) ]).stdout?.pipe(process.stdout);
}

added a new index.js file to the generator folder with the following code ..,

module.exports = {
    params: ({ args }) => {
       return JSON.parse(args.name);
  }
}

While this works.. I think there could be a more elegant way to execute this approach without having to create the boiler-plate code. Suggestions for a more elegant option?

Anyway, love the library and simplicity.

@rogrdat rogrdat changed the title JSON string as value of args parameter [Solved] JSON payload to generator Jul 2, 2022
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