mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 19:22:56 +00:00
More TGUI Maintenance
This commit is contained in:
@@ -4,26 +4,26 @@
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
import glob from 'glob';
|
||||
import { resolve as resolvePath } from 'path';
|
||||
import fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import path from 'path';
|
||||
import { require } from './require.js';
|
||||
|
||||
export { resolvePath };
|
||||
const globPkg = require('glob');
|
||||
|
||||
export const resolvePath = path.resolve;
|
||||
|
||||
/**
|
||||
* Combines path.resolve with glob patterns.
|
||||
*/
|
||||
export const resolveGlob = async (...sections) => {
|
||||
const unsafePaths = await promisify(glob)(
|
||||
resolvePath(...sections), {
|
||||
strict: false,
|
||||
silent: true,
|
||||
});
|
||||
export const resolveGlob = (...sections) => {
|
||||
const unsafePaths = globPkg.sync(path.resolve(...sections), {
|
||||
strict: false,
|
||||
silent: true,
|
||||
});
|
||||
const safePaths = [];
|
||||
for (let path of unsafePaths) {
|
||||
try {
|
||||
await promisify(fs.stat)(path);
|
||||
fs.statSync(path);
|
||||
safePaths.push(path);
|
||||
}
|
||||
catch {}
|
||||
|
||||
Reference in New Issue
Block a user