3ec9ff9a4d5ab16f9068622470c9a9b16b477af3725a6ee1d9cf47d3eb95a11c546f8623bc658e323afc8d51df59ba068c0af4937c801fec058632735a9e44 539 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const path = require('path');
  3. const pathExists = require('path-exists');
  4. const pLocate = require('p-locate');
  5. module.exports = (iterable, options) => {
  6. options = Object.assign({
  7. cwd: process.cwd()
  8. }, options);
  9. return pLocate(iterable, el => pathExists(path.resolve(options.cwd, el)), options);
  10. };
  11. module.exports.sync = (iterable, options) => {
  12. options = Object.assign({
  13. cwd: process.cwd()
  14. }, options);
  15. for (const el of iterable) {
  16. if (pathExists.sync(path.resolve(options.cwd, el))) {
  17. return el;
  18. }
  19. }
  20. };