Files
CHOMPStation2/tgui/packages/tgui-dev-server/util.js
CHOMPStation2 85ca379bb2 [MIRROR] [TGUI 5.0 Prep] JS to JSX (#7414)
Co-authored-by: Selis <sirlionfur@hotmail.de>
Co-authored-by: Selis <selis@xynolabs.com>
2023-12-13 23:23:03 +01:00

32 lines
598 B
JavaScript

/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import fs from 'fs';
import path from 'path';
import { require } from './require';
const globPkg = require('glob');
export const resolvePath = path.resolve;
/**
* Combines path.resolve with glob patterns.
*/
export const resolveGlob = (...sections) => {
const unsafePaths = globPkg.sync(path.resolve(...sections), {
strict: false,
silent: true,
});
const safePaths = [];
for (let path of unsafePaths) {
try {
fs.statSync(path);
safePaths.push(path);
} catch {}
}
return safePaths;
};