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