tdgbench-studio / scripts /validate-executable-command.js
othmanekabal's picture
Do not preselect unavailable RGCN artifact results
190bb48 verified
Raw History Blame Contribute Delete
687 Bytes
const fs = require('fs');
const vm = require('vm');
const context = { btoa: value => Buffer.from(value, 'binary').toString('base64') };
vm.createContext(context);
vm.runInContext(fs.readFileSync('assets/js/core/utils.js', 'utf8'), context);
const source = 'print("TDGBench command ready")';
const command = context.pythonCommand(source);
const payload = command.match(/b64decode\('([^']+)'\)/)?.[1];
if (!command.startsWith('python -c "') || !payload || Buffer.from(payload, 'base64').toString('utf8') !== source) {
throw new Error(`Generated command is invalid:\n${command}`);
}
console.log('Commande exécutable valide : le code Python généré peut être lancé directement.');