Created
May 21, 2024 14:06
-
-
Save rofe/4c859fc6caee0d60668e50712f7b5396 to your computer and use it in GitHub Desktop.
filter mountpoints in inventory.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console, header/header, import/no-extraneous-dependencies */ | |
import fs from 'fs-extra'; | |
function filter(filters) { | |
return (mp) => filters.every((f) => { | |
if (f.startsWith('-')) { | |
return !mp.includes(f.substring(1)); | |
} else { | |
return mp.includes(f); | |
} | |
}); | |
} | |
async function listMountPoints() { | |
const json = await fs.readJson('inventory.json'); | |
const og = Object.values(json.entries); | |
const mps = og | |
.map((project) => project.contentSourceUrl) | |
.filter(filter(process.argv.slice(2))); | |
mps.forEach((mp) => console.log(mp)); | |
console.log(`Returned ${mps.length} of ${og.length} mountpoints`); | |
} | |
listMountPoints(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment