mirror of
https://github.com/zumbiepig/MineXLauncher.git
synced 2025-06-26 10:05:10 +00:00
move to bun
This commit is contained in:
21
generateAssetsList.ts
Normal file
21
generateAssetsList.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { readdirSync, statSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
const directoryPath = join(import.meta.dir, 'public');
|
||||
|
||||
function getFiles(dir: string, filesArr?: string[]) {
|
||||
filesArr = filesArr || [];
|
||||
const files = readdirSync(dir);
|
||||
for (const file of files) {
|
||||
const name = join(dir, file);
|
||||
if (statSync(name).isDirectory()) {
|
||||
getFiles(name, filesArr);
|
||||
} else {
|
||||
filesArr.push(name.replace(new RegExp(`^${directoryPath}`), '').replace(/\/index\.html$/, '/'));
|
||||
}
|
||||
}
|
||||
return filesArr;
|
||||
}
|
||||
|
||||
const assets = getFiles(directoryPath);
|
||||
writeFileSync(join(directoryPath, 'assets.json'), JSON.stringify(assets));
|
||||
Reference in New Issue
Block a user