1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.isGlob = isGlob;
|
7 | exports.isGlobMatch = isGlobMatch;
|
8 | exports.globSync = globSync;
|
9 | exports.glob = glob;
|
10 |
|
11 | var _isGlob2 = _interopRequireDefault(require("is-glob"));
|
12 |
|
13 | var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
14 |
|
15 | var _micromatch = require("micromatch");
|
16 |
|
17 | var _path = require("./path");
|
18 |
|
19 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20 |
|
21 | function isGlob(p) {
|
22 | return (0, _isGlob2.default)((0, _path.normalizeSeparators)(p));
|
23 | }
|
24 |
|
25 | function isGlobMatch(filePath, glob) {
|
26 | return (0, _micromatch.isMatch)(filePath, (0, _path.normalizeSeparators)(glob));
|
27 | }
|
28 |
|
29 | function globSync(p, options) {
|
30 | return _fastGlob.default.sync((0, _path.normalizeSeparators)(p), options);
|
31 | }
|
32 |
|
33 | function glob(p, fs, options) {
|
34 |
|
35 | options = { ...options,
|
36 | fs: {
|
37 | stat: async (p, cb) => {
|
38 | try {
|
39 | cb(null, (await fs.stat(p)));
|
40 | } catch (err) {
|
41 | cb(err);
|
42 | }
|
43 | },
|
44 | lstat: async (p, cb) => {
|
45 |
|
46 |
|
47 | try {
|
48 | cb(null, (await fs.stat(p)));
|
49 | } catch (err) {
|
50 | cb(err);
|
51 | }
|
52 | },
|
53 | readdir: async (p, opts, cb) => {
|
54 | if (typeof opts === 'function') {
|
55 | cb = opts;
|
56 | opts = null;
|
57 | }
|
58 |
|
59 | try {
|
60 | cb(null, (await fs.readdir(p, opts)));
|
61 | } catch (err) {
|
62 | cb(err);
|
63 | }
|
64 | }
|
65 | }
|
66 | };
|
67 |
|
68 | return (0, _fastGlob.default)((0, _path.normalizeSeparators)(p), options);
|
69 | } |
\ | No newline at end of file |