-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind.js
30 lines (26 loc) · 952 Bytes
/
find.js
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
const fs = require('fs');
const path = require('path');
const outputFolderPath = path.join(__dirname, 'data');
function findPart(partName) {
const mods = fs.readdirSync(outputFolderPath);
for (const mod of mods) {
const partsJsonPath = path.join(outputFolderPath, mod, 'parts.json');
if (fs.existsSync(partsJsonPath)) {
const partsJson = JSON.parse(fs.readFileSync(partsJsonPath, 'utf8'));
const foundPart = partsJson.find(part => part.name === partName);
if (foundPart) {
console.log(`Part "${partName}" found in mod "${mod}"`);
return;
}
}
}
console.log(`Part "${partName}" not found in any mod`);
}
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question('Enter the name of a part: ', (partName) => {
findPart(partName);
readline.close();
});