2024-03-24 14:31:20 -04:00
|
|
|
const fs = require('fs');
|
2024-03-24 14:43:49 -04:00
|
|
|
const path = require('path');
|
2024-03-24 14:31:20 -04:00
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
|
|
let result = {};
|
|
|
|
|
2024-03-24 14:43:49 -04:00
|
|
|
function getDirectories(path) {
|
|
|
|
return fs.readdirSync(path, { withFileTypes: true })
|
|
|
|
.filter(dirent => dirent.isDirectory())
|
|
|
|
.map(dirent => dirent.name);
|
|
|
|
}
|
2024-03-24 14:31:20 -04:00
|
|
|
|
2024-03-24 14:43:49 -04:00
|
|
|
let directories = getDirectories('samples');
|
|
|
|
directories.forEach(directory => {
|
|
|
|
let assetsPath = path.join('samples', directory, 'assets');
|
|
|
|
if (fs.existsSync(assetsPath)) {
|
|
|
|
let files = fs.readdirSync(assetsPath);
|
|
|
|
files.forEach(file => {
|
|
|
|
if (file === 'sample.json') {
|
|
|
|
let data = JSON.parse(fs.readFileSync(path.join(assetsPath, file)));
|
|
|
|
result = _.merge(result, data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
fs.writeFileSync('samples.json', JSON.stringify(result));
|