61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
import { Client } from 'ssh2';
|
|
|
|
const conn = new Client();
|
|
|
|
conn.on('ready', () => {
|
|
console.log('=== 重新构建H5 ===\n');
|
|
|
|
conn.exec('cd /www/huishou && npm run build:h5 2>&1', (err, stream) => {
|
|
if (err) {
|
|
console.log('构建失败:', err.message);
|
|
conn.end();
|
|
return;
|
|
}
|
|
|
|
let output = '';
|
|
stream.on('data', (data) => {
|
|
output += data.toString();
|
|
});
|
|
|
|
stream.on('close', () => {
|
|
console.log('构建输出:', output.substring(output.length - 500));
|
|
|
|
conn.exec('ls -la /www/huishou/dist/build/h5/assets/index*.js | head -5', (err, stream2) => {
|
|
if (err) {
|
|
console.log('检查JS失败:', err.message);
|
|
} else {
|
|
stream2.on('data', (data2) => {
|
|
console.log('\nJS文件:', data2.toString());
|
|
}
|
|
}
|
|
|
|
stream2.on('close', () => {
|
|
conn.exec('cat /www/huishou/dist/build/h5/index.html', (err, stream3) => {
|
|
if (err) {
|
|
console.log('读取HTML失败:', err.message);
|
|
} else {
|
|
stream3.on('data', (data3) => {
|
|
console.log('\nindex.html:', data3.toString());
|
|
}
|
|
}
|
|
|
|
stream3.on('close', () => {
|
|
conn.end();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
conn.on('error', (err) => {
|
|
console.log('连接错误:', err.message);
|
|
});
|
|
|
|
conn.connect({
|
|
host: 'hs.yifenbao.cn',
|
|
port: 22,
|
|
username: 'root',
|
|
password: 'Torch1112'
|
|
}); |