-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateGameList.ts
More file actions
32 lines (27 loc) · 859 Bytes
/
Copy pathgenerateGameList.ts
File metadata and controls
32 lines (27 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('fs');
const path = require('path');
const gamesDir = path.join(__dirname, 'src', 'Games');
const outputFilePath = path.join(__dirname, 'src', 'gamesList.json');
fs.readdir(gamesDir, (err, files) => {
if (err) {
console.error('Error reading games directory:', err);
return;
}
const gameNames = files
.filter(
(file) =>
file.endsWith('.jsx') ||
file.endsWith('.tsx') ||
file.endsWith('.ts') ||
file.endsWith('.js')
) // Adjust extensions as needed
.map((file) => path.basename(file, path.extname(file)));
fs.writeFile(outputFilePath, JSON.stringify(gameNames, null, 2), (err) => {
if (err) {
console.error('Error writing games list file:', err);
} else {
console.log('Games list generated successfully.');
}
});
});
// node generateGameList.js