Open michal-bella opened 7 months ago
Hey, have you found a solution for this?
I use child_process
:
const { exec } = require('child_process');
// ...
plop.setActionType('runCommand', function (answers, config, plop) {
return new Promise((resolve, reject) => {
exec(config.command, (error, stdout, stderr) => {
if (error) {
console.error(`Errore: ${error.message}`);
reject(error);
}
if (stderr) {
console.error(`Stderr: ${stderr}`);
reject(new Error(stderr));
}
console.log(`Risultato: ${stdout}`);
resolve(stdout);
});
});
});
actions: [
// ...
{
type: 'runCommand',
command: 'npm run [COMMAND]',
}
]
Hello, can you add action type that trigger shell command? For example I want to achive during generating my code I want to trigger npm install "some-package". It would be nice to have this type of action.
{ type: 'command', command: 'npm install @some-package' // or any other command }