mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-05-20 13:47:12 +01:00
97bd12b862
* removes tgui sonar, dev server oversights * Update retrace.ts * tgui-core up * update depts * . * . * be gone IE stuff * . * prettier * . * . * . * up for bins * . * . * . * . * . * fix that * .
41 lines
857 B
TypeScript
41 lines
857 B
TypeScript
/**
|
|
* @file
|
|
* @copyright 2020 Aleksej Komarov
|
|
* @license MIT
|
|
*/
|
|
|
|
import path from 'node:path';
|
|
|
|
import { Glob } from 'bun';
|
|
|
|
export const resolvePath = path.resolve;
|
|
|
|
/** Combines path.resolve with glob patterns. */
|
|
export async function resolveGlob(
|
|
directory: string,
|
|
pattern = '*',
|
|
): Promise<string[]> {
|
|
// If no pattern is supplied, just return the directory if it exists
|
|
if (pattern === '*') {
|
|
try {
|
|
const stat = await Bun.file(directory).stat();
|
|
if (stat?.isDirectory()) {
|
|
return [directory];
|
|
}
|
|
} catch (e) {
|
|
return [];
|
|
}
|
|
return [];
|
|
}
|
|
|
|
// Otherwise, use glob logic
|
|
const glob = new Glob(pattern);
|
|
const results: string[] = [];
|
|
|
|
for await (const match of glob.scan({ onlyFiles: false, cwd: directory })) {
|
|
results.push(path.resolve(directory, match));
|
|
}
|
|
|
|
return results;
|
|
}
|