Skip to content

Commit

Permalink
mommyyyy!
Browse files Browse the repository at this point in the history
  • Loading branch information
g9aerospace committed Mar 14, 2024
1 parent 50fa610 commit 3947b53
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions findpart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const fs = require('fs');
const path = require('path');

function findPart(partName, directory) {
const files = fs.readdirSync(directory);

for (const file of files) {
const filePath = path.join(directory, file);
const stat = fs.statSync(filePath);

if (stat.isDirectory()) {
const result = findPart(partName, filePath);
if (result) {
return result;
}
} else if (file.endsWith('.cfg')) {
const content = fs.readFileSync(filePath, 'utf-8');
if (content.includes(`name = ${partName}`)) {
return filePath;
}
}
}

return null;
}

const partName = process.argv[2];

if (!partName) {
console.log('Please provide a part name as an argument.');
process.exit(1);
}

const gamedataPath = path.join(__dirname, 'GameData');
const partPath = findPart(partName, gamedataPath);

if (partPath) {
console.log(`Part '${partName}' found at: ${partPath}`);
} else {
console.log(`Part '${partName}' not found.`);
}

0 comments on commit 3947b53

Please sign in to comment.