Files
JeremiahandRoxy 2f4efa74c9 [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 03:28:34 -04:00

53 lines
1.2 KiB
TypeScript

/**
* Tools for dealing with Windows Registry bullshit.
*
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
import { createLogger } from './logging';
const logger = createLogger('winreg');
/** Query a registry key. */
export async function regQuery(
path: string,
key: string,
): Promise<string | undefined> {
if (process.platform !== 'win32') {
return;
}
try {
const command = `reg query "${path}" /v ${key}`;
const { stdout } = await promisify(exec)(command);
const keyPattern = ` ${key} `;
const indexOfKey = stdout.indexOf(keyPattern);
if (indexOfKey === -1) {
logger.error('could not find the registry key');
return;
}
const indexOfEol = stdout.indexOf('\r\n', indexOfKey);
if (indexOfEol === -1) {
logger.error('could not find the end of the line');
return;
}
const indexOfValue = stdout.indexOf(' ', indexOfKey + keyPattern.length);
if (indexOfValue === -1) {
logger.error('could not find the start of the key value');
return;
}
return stdout.substring(indexOfValue + 4, indexOfEol);
} catch (err) {
logger.error(err);
return;
}
}