Files
Jeremiah 6dccb679c0 [tgui] Reworks dev server into Bun + TS (#91695)
## About The Pull Request
This started out as just a small fix for dev server crashing but lo, I
cannot keep my hands off of such a juicy rework, it now uses Bun's own
websocket server and is written entirely in typescript. It makes much
more use of console.log (you can see these in client) as well
## Why It's Good For The Game
Lets devs use tgui-dev again

## Changelog
2025-06-22 00:17:28 -07:00

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;
}