INNER CODE UNIT · JavaScript

getAllJsonFiles

ImranR98/apps.obtainium.imranr.dev · scripts/generate_from_export.js:38

function getAllJsonFiles(dir) {
    const results = []
    for (const item of fs.readdirSync(dir, { withFileTypes: true })) {
        const fullPath = path.join(dir, item.name)
        if (item.isDirectory()) {
            results.push(...getAllJsonFiles(fullPath))
        } else if (item.name.toLowerCase().endsWith('.json')) {
            results.push(fullPath)
        }
    }
    return results
}

function getAppIds(filePath) {
    try {
        const data = JSON.parse(fs.readFileSync(filePath, 'utf8'))
        return [data.config?.id, ...(data.configs ?? []).map(c => c.id)].filter(Boolean)
    } catch (err) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…