33 lines
655 B
JavaScript
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())
|
|
}
|
|
} |