1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getExistFile = getExistFile;
|
7 |
|
8 | var _fs = require("fs");
|
9 |
|
10 | var _path = require("path");
|
11 |
|
12 | function getExistFile({
|
13 | cwd,
|
14 | files,
|
15 | returnRelative
|
16 | }) {
|
17 | var _iteratorNormalCompletion = true;
|
18 | var _didIteratorError = false;
|
19 | var _iteratorError = undefined;
|
20 |
|
21 | try {
|
22 | for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
23 | const file = _step.value;
|
24 | const absFilePath = (0, _path.join)(cwd, file);
|
25 |
|
26 | if ((0, _fs.existsSync)(absFilePath)) {
|
27 | return returnRelative ? file : absFilePath;
|
28 | }
|
29 | }
|
30 | } catch (err) {
|
31 | _didIteratorError = true;
|
32 | _iteratorError = err;
|
33 | } finally {
|
34 | try {
|
35 | if (!_iteratorNormalCompletion && _iterator.return != null) {
|
36 | _iterator.return();
|
37 | }
|
38 | } finally {
|
39 | if (_didIteratorError) {
|
40 | throw _iteratorError;
|
41 | }
|
42 | }
|
43 | }
|
44 | } |
\ | No newline at end of file |