๐Ÿ“ฆ colinhacks / bye-react

๐Ÿ“„ runCommands.js ยท 29 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29const { exec } = require('child_process');

let runCommands = (commands)=>{
  return new Promise((res,rej)=>{
    if(!commands.length){
      return res()
    }
    let command = commands.shift()
    console.log("> "+command)

    const options = {maxBuffer: 1024 * 1700}
    let execution = exec(command, options, (err, stdout, stderr) => {
      if(err){
        console.log(err)
        return rej(err)
      }
      return runCommands(commands).then(()=>{
        if(!commands.length){
          res(true)
          return
        }
      })
    })
    execution.stdout.pipe(process.stdout);
    execution.stderr.pipe(process.stderr);
  })
}

module.exports = runCommands