mothercup/hardware_design/_dump_run.mjs
2026-09-12 10:52:17 +08:00

15 lines
761 B
JavaScript

import { readFileSync, writeFileSync } from 'node:fs';
import { request } from 'node:http';
const code = readFileSync('H:/caiic_workspace/mothercup/hardware_design/_dump.js', 'utf8');
const body = JSON.stringify({ code });
const req = request({ host: '127.0.0.1', port: 49620, path: '/execute', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) } }, res => {
let d = '';
res.on('data', c => d += c);
res.on('end', () => {
const j = JSON.parse(d);
if (j.success) { writeFileSync('H:/caiic_workspace/mothercup/hardware_design/_dump.json', JSON.stringify(j.result)); console.log('saved', JSON.stringify(j.result).length); }
else console.log('FAIL', d);
});
});
req.write(body); req.end();