`internal/gen/**` → /^internal\/gen\/.*$/ . Supports `**`, `*` and literals.
(glob)
| 71 | |
| 72 | /** `internal/gen/**` → /^internal\/gen\/.*$/ . Supports `**`, `*` and literals. */ |
| 73 | function globToRegExp(glob) { |
| 74 | // Park `**` on a sentinel no path can contain, so the `*` pass cannot eat it. |
| 75 | // Written as an escape, not a literal byte — a raw NUL makes git treat this |
| 76 | // whole script as binary, which costs every future diff of it. |
| 77 | const DOUBLE_STAR = '\u0000'; |
| 78 | const escaped = glob.replace(/[.+^${}()|[\]\\]/g, '\\$&'); |
| 79 | const body = escaped |
| 80 | .replace(/\*\*/g, DOUBLE_STAR) |
| 81 | .replace(/\*/g, '[^/]*') |
| 82 | .replaceAll(DOUBLE_STAR, '.*'); |
| 83 | return new RegExp(`^${body}$`); |
| 84 | } |
| 85 | |
| 86 | const groupOf = (path, groups) => { |
| 87 | for (const [name, globs] of Object.entries(groups)) { |