|
1 | 1 | import { createHash } from 'crypto';
|
2 |
| -import { glob, hasMagic } from 'glob'; |
| 2 | +import { Minimatch } from 'minimatch'; |
| 3 | +import * as fg from 'fast-glob'; |
3 | 4 | import * as path from 'path';
|
4 | 5 | import * as fs from 'fs';
|
5 | 6 | import { RedisClient } from '../interfaces';
|
@@ -74,9 +75,19 @@ export class ScriptLoaderError extends Error {
|
74 | 75 | }
|
75 | 76 | }
|
76 | 77 |
|
| 78 | +const hasMagic = (pattern: string | string[]): boolean => { |
| 79 | + if (!Array.isArray(pattern)) { |
| 80 | + pattern = [pattern]; |
| 81 | + } |
| 82 | + for (const p of pattern) { |
| 83 | + if (new Minimatch(p, GlobOptions).hasMagic()) {return true;} |
| 84 | + } |
| 85 | + return false; |
| 86 | +}; |
| 87 | + |
77 | 88 | const isPossiblyMappedPath = (path: string) =>
|
78 | 89 | path && ['~', '<'].includes(path[0]);
|
79 |
| -const hasFilenamePattern = (path: string) => hasMagic(path, GlobOptions); |
| 90 | +const hasFilenamePattern = (path: string) => hasMagic(path); |
80 | 91 |
|
81 | 92 | /**
|
82 | 93 | * Lua script loader with include support
|
@@ -487,11 +498,7 @@ function splitFilename(filePath: string): {
|
487 | 498 | }
|
488 | 499 |
|
489 | 500 | async function getFilenamesByPattern(pattern: string): Promise<string[]> {
|
490 |
| - return new Promise<string[]>((resolve, reject) => { |
491 |
| - glob(pattern, GlobOptions, (err, files) => { |
492 |
| - return err ? reject(err) : resolve(files); |
493 |
| - }); |
494 |
| - }); |
| 501 | + return fg.glob(pattern, { dot: true }); |
495 | 502 | }
|
496 | 503 |
|
497 | 504 | // Determine the project root
|
|
0 commit comments