-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50fa610
commit 3947b53
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
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
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.`); | ||
} |