Files
kit.program/kit/src/shell/index.js
T
2025-03-11 16:50:44 +08:00

33 lines
655 B
JavaScript

/**
*
* child_process
* - exec 适合短时间命令,获取完整输出
* - execFile 适合实时交互
* - spawn 适合长时间命令
*
* shelljs - https://www.npmjs.com/package/shelljs
* execa - https://www.npmjs.com/package/execa
* ssh2 - https://www.npmjs.com/package/ssh2
*
*/
const { execSync } = require('child_process');
module.exports = {
execSync(cmd){
$logger.debug(`execSync ${cmd}`)
const output = execSync(cmd);
return output.toString()
},
callSync(cmd){
$logger.debug(`callSync ${cmd}`)
const output = execSync(cmd);
console.log(output.toString())
}
}