.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / locate-path / index.js
1 'use strict';
2 const path = require('path');
3 const pathExists = require('path-exists');
4 const pLocate = require('p-locate');
5
6 module.exports = (iterable, opts) => {
7         opts = Object.assign({
8                 cwd: process.cwd()
9         }, opts);
10
11         return pLocate(iterable, el => pathExists(path.resolve(opts.cwd, el)), opts);
12 };
13
14 module.exports.sync = (iterable, opts) => {
15         opts = Object.assign({
16                 cwd: process.cwd()
17         }, opts);
18
19         for (const el of iterable) {
20                 if (pathExists.sync(path.resolve(opts.cwd, el))) {
21                         return el;
22                 }
23         }
24 };