This repository was archived by the owner on Aug 21, 2025. It is now read-only.
forked from BeamNG/vscode-jbeam-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodLoad.js
More file actions
43 lines (37 loc) · 1.25 KB
/
Copy pathmodLoad.js
File metadata and controls
43 lines (37 loc) · 1.25 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
const AdmZip = require('adm-zip');
const fs = require('fs');
const path = require('path');
const readline = require('readline');
// Function to load a mod from a zip file and extract it
function loadMod(zipFilePath, extractTo) {
// Check if the zip file exists
if (!fs.existsSync(zipFilePath)) {
console.error(`File not found: ${zipFilePath}`);
return;
}
try {
// Load the zip file
const zip = new AdmZip(zipFilePath);
// Extract the content to the specified directory
zip.extractAllTo(extractTo, true); // 'true' overwrites files if they exist
console.log(`Mod extracted to ${extractTo}`);
} catch (error) {
console.error(`Failed to extract mod: ${error}`);
}
}
// Function to prompt the user for input
function promptUser() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('Enter the path to the zip file: ', (zipFilePath) => {
rl.question('Enter the path to the extraction directory: ', (extractTo) => {
// Call the function to load and extract the mod
loadMod(zipFilePath, extractTo);
rl.close();
});
});
}
// Start the prompt
promptUser();