UNPKG

indexr

Version:

Automated dynamic indexes for your ES6+ source code.

45 lines (32 loc) 1.16 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _glob = require('glob'); var _glob2 = _interopRequireDefault(_glob); var _lodash = require('lodash.flatten'); var _lodash2 = _interopRequireDefault(_lodash); var _lodash3 = require('lodash.uniq'); var _lodash4 = _interopRequireDefault(_lodash3); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function (cwd, globs, ignore) { return new Promise(function (resolve, reject) { if (globs) { var patterns = Array.isArray(globs) ? globs : [globs]; Promise.all(patterns.map(function (pattern) { return new Promise(function (res) { (0, _glob2.default)(pattern, { cwd: cwd, ignore: ignore }, function (err, result) { res(result.sort()); // results of wildglob are not ordered. }); }); })).then(function (results) { resolve((0, _lodash4.default)((0, _lodash2.default)(results))); }).catch(function (e) { reject(e); }); } else { resolve([cwd]); } }); }; module.exports = exports['default'];