const { Client } = require('ssh2'); const conn = new Client(); conn.on('ready', () => { console.log('=== 验证最终上传结果 ==='); // 检查index.html引用的主JS文件 conn.exec('grep -o "src=\".*index-[^\"]*\"" /www/huishou/dist/build/h5/index.html', (err, stream) => { if (err) { console.log('ERR:', err); } else { stream.on('data', (d) => { const match = d.toString().match(/index-([^\"]+)/); if (match) { console.log('当前主JS文件: index-' + match[1]); // 检查这个文件是否包含累加代码 conn.exec(`grep -c "add-btn\|累加" /www/huishou/dist/build/h5/assets/index-${match[1]}.js`, (err2, stream2) => { if (err2) console.log('ERR2:', err2); else stream2.on('data', (d2) => console.log('主JS文件中累加代码数量:', d2.toString())); stream2.on('close', () => conn.end()); }); } }); } }); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });