/ script / lib / expand-glob-paths.js
expand-glob-paths.js
 1  'use strict';
 2  
 3  const glob = require('glob');
 4  
 5  module.exports = function(globPaths) {
 6    return Promise.all(globPaths.map(g => expandGlobPath(g))).then(paths =>
 7      paths.reduce((a, b) => a.concat(b), [])
 8    );
 9  };
10  
11  function expandGlobPath(globPath) {
12    return new Promise((resolve, reject) => {
13      glob(globPath, (error, paths) => {
14        if (error) {
15          reject(error);
16        } else {
17          resolve(paths);
18        }
19      });
20    });
21  }