title: Node.Js - exit out of exec after continuous commands
body: <p>I'm executing a few git commands in sequence, in particular, I'm following a git flow model,</p>
  
  <p>e.g. when finishing a feature, I run,</p>
  
  <pre><code>git pull
  git push -u origin branchname
  git pull origin develop
  git checkout develop
  git merge branchname
  git push
  </code></pre>
  
  <p>I run these commands using the <code>exec</code> module in node.js and I chain them one after another, like:</p>
  
  <pre><code>exec(command1,
       (err, stdout, stderr) =&gt; {
              if(err != null) {
                    //display an error message
                    return
              } else {
                    exec(command2, (err, stdout, stderr) =&gt;{ ... }
              }
  
        }
  )
  </code></pre>
  
  <p>And so on. The outputs are working correctly and the order is working. However, if one of those commands fail, I am breaking out of the chain.</p>
  
  <p>I know that there is an async library that I could use with the same effect, per <a href="https://stackoverflow.com/questions/32559822/how-to-stop-executing-waterfall-on-error-in-async-of-node-js">here</a>. However, is this the best possible way to do that without resorting to a third-party library? How have other people done it?</p>