Expands one `*` in a path segment, newest match first.
(pattern)
| 58 | |
| 59 | /** Expands one `*` in a path segment, newest match first. */ |
| 60 | function glob(pattern) { |
| 61 | const [head, ...rest] = pattern.split('*'); |
| 62 | const base = dirname(head); |
| 63 | const prefix = head.slice(base.length + 1); |
| 64 | if (!existsSync(base)) return []; |
| 65 | return readdirSync(base) |
| 66 | .filter((name) => name.startsWith(prefix)) |
| 67 | .sort() |
| 68 | .reverse() |
| 69 | .map((name) => join(base, name) + rest.join('*')); |
| 70 | } |
| 71 | |
| 72 | function findBrowser() { |
| 73 | const home = process.env.HOME ?? ''; |