-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateWallpapers.js
More file actions
38 lines (30 loc) · 1.08 KB
/
generateWallpapers.js
File metadata and controls
38 lines (30 loc) · 1.08 KB
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
33
34
35
36
37
38
const fs = require('fs');
const path = require('path');
const wallpapersDir = path.join(__dirname, '..', 'public', 'images', 'stories', 'wallies');
const outputFile = path.join(__dirname, '..', 'src', 'utils', 'dndWallpapers.js');
fs.readdir(wallpapersDir, (err, files) => {
if (err) {
console.error('Error reading wallpapers directory:', err);
return;
}
const imageFiles = files.filter(file => {
const ext = path.extname(file).toLowerCase();
return ext === '.jpg' || ext === '.png' || ext === '.jpeg' || ext === '.gif';
});
// Construct each path string with quotes and indentation
const formattedPaths = imageFiles.map(file => ` '/images/stories/wallies/${file}'`);
// Join them with a comma and newline
const arrayContent = formattedPaths.join(',\n');
const content = `const dndWallpapers = [
${arrayContent}
];
export default dndWallpapers;
`;
fs.writeFile(outputFile, content, err => {
if (err) {
console.error('Error writing dndWallpapers.js:', err);
return;
}
console.log('dndWallpapers.js generated successfully!');
});
});