Skip to content

Commit 2603489

Browse files
committed
🛠️ README.md -> Updated usage example for @kspcommunity/craft-file-reader
🔴 test.js
1 parent 53c72b6 commit 2603489

2 files changed

Lines changed: 41 additions & 40 deletions

File tree

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,47 @@ npm install @kspcommunity/craft-file-reader
2121

2222
## Usage
2323

24-
See the test.js
24+
```javascript
25+
const processCraftFile = require("@kspcommunity/craft-file-reader");
26+
27+
// Path to the Craft file
28+
const craftFilePath = 'example.craft';
29+
30+
// Call the processCraftFile function to process the Craft file
31+
processCraftFile(craftFilePath)
32+
.then(processedCraftData => {
33+
if (processedCraftData) {
34+
// Print craft details
35+
console.log('\nCraft Details:');
36+
console.log(`- Ship: ${processedCraftData.craftDetails.ship}`);
37+
console.log(`- Description: ${processedCraftData.craftDetails.description}`);
38+
console.log(`- Version: ${processedCraftData.craftDetails.version}`);
39+
console.log(`- Type: ${processedCraftData.craftDetails.type}`);
40+
console.log(`- Size: ${processedCraftData.craftDetails.size}`);
41+
console.log(`- Vessel Type: ${processedCraftData.craftDetails.vesselType}`);
42+
console.log(`- Total Part Count: ${processedCraftData.craftDetails.totalPartCount}`);
43+
44+
// Print parts details
45+
console.log('\nParts in the craft file:');
46+
for (const partDetails of processedCraftData.partsDetails) {
47+
if (partDetails.notFoundInModData) {
48+
console.log(`\nPart: ${partDetails.partName} (Not found in mod parts data)`);
49+
} else {
50+
console.log(`\n Part: ${partDetails.partName}`);
51+
console.log(` Mod: ${partDetails.modName}`);
52+
console.log(` Mod Preferred Name: ${partDetails.preferredName}`);
53+
console.log(` Link: ${partDetails.link}`);
54+
console.log(` File Path: ${partDetails.filePath}`);
55+
}
56+
}
57+
} else {
58+
console.log('Failed to process the Craft file.');
59+
}
60+
})
61+
.catch(error => {
62+
console.error('Error processing the Craft file:', error);
63+
});
64+
```
2565

2666
## Interact with Mod Parts Data
2767

test.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)