exec-promise.js 286 B

123456789101112131415
  1. const child_process = require('child_process')
  2. // 执行命令
  3. function exec(cmd) {
  4. return new Promise((resolve, reject) => {
  5. child_process.exec(cmd, (error, stdout) => {
  6. if (error) {
  7. reject(error)
  8. }
  9. resolve(stdout)
  10. })
  11. })
  12. }
  13. module.exports = exec