import {NodePlopAPI} from "plop"; import { exec, spawn } from 'child_process'; import Handlebars from "handlebars"; export function runCommandActionType(plop: NodePlopAPI) { plop.setActionType('runCommand', function (answers, config, plop) { return new Promise((resolve, reject) => { const command = spawn(plop.renderString(config.command, answers), { shell: true, stdio: 'inherit' }); command.on('close', (code) => { if (code !== 0) { reject(`La commande a échoué avec le code : ${code}`); } else { resolve('Commande exécutée avec succès'); } }); }); }); }