[Solved] JSON payload to generator
rogrdat opened this issue · comments
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);
}
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.