How to return promise.map (bluebird) inside a promise chain?
<p>I'm using a chain to control flow and can't get promise.map in <code>step2()</code> to wait until all of it's generated promises are resolved.</p>

<p>Here's a visual of the flow I'm trying to achieve. </p>

<p><code>step1()
       step2()
       step2()
       step2()
       step2()
              step3()</code></p>

<p>In <code>step2()</code> I'm using Bluebird's promise.map.</p>

<p>Here's the chain:</p>

<pre class="lang-js prettyprint-override"><code>step1()
  .then(function() { return step2() }) 
  .then(function() { return step3() })
  .catch(function() { // handle errors })
</code></pre>

<p>Here's my functions for each step:</p>

<pre class="lang-js prettyprint-override"><code>let step1 = function() {
  return new Promise(function(resolve, reject) {      
    // do stuff
    resolve()
  })
}

let step2 = function() {
  return new Promise(function(resolve, reject) {
    things = []      
    return Promise.map(things, function(thing) {
      // load file async with callback
    })
    resolve()
  })
}

let step3 = function() {
  return new Promise(function(resolve, reject) {      
    // do stuff
    resolve()
  })
}
</code></pre>

<p>I've tested the chain with many more steps each with a <code>timeout</code> and it worked as expected with the exception of the promise.map in <code>step2()</code>. What am I doing wrong? :)</p>