build: modify the SVR.JS installation script to extract all files from the archive

This commit is contained in:
Dorian Niemiec 2025-01-02 13:48:37 +01:00
parent 17363178cd
commit 6bea2e78cc

View file

@ -42,27 +42,21 @@ function downloadSVRJS(version) {
const reader = zip.Reader(zipData); const reader = zip.Reader(zipData);
const allFiles = reader.toObject(); const allFiles = reader.toObject();
Object.keys(allFiles).forEach((filename) => { Object.keys(allFiles).forEach((filename) => {
var paths = filename.split("/"); const paths = filename.split("/");
if ( for (let i = 0; i < paths.length - 1; i++) {
filename.match( const dirname = JSON.parse(JSON.stringify(paths))
/^(?:[^/.]+\.compressed|(?:log(?:viewer|highlight)|svr(?:passwd|_new)?)\.js|node_modules(?:\/|$))/ .splice(0, i + 1)
) .join("/");
) { if (!fs.existsSync(__dirname + "/svrjs/" + dirname)) {
for (var j = 0; j < paths.length - 1; j++) { fs.mkdirSync(__dirname + "/svrjs/" + dirname);
const dirname = JSON.parse(JSON.stringify(paths))
.splice(0, j + 1)
.join("/");
if (!fs.existsSync(__dirname + "/svrjs/" + dirname)) {
fs.mkdirSync(__dirname + "/svrjs/" + dirname);
}
} }
fs.writeFileSync(
__dirname + "/svrjs/" + filename,
allFiles[filename]
);
} }
fs.writeFileSync(
__dirname + "/svrjs/" + filename,
allFiles[filename]
);
}); });
fs.mkdirSync(__dirname + "/svrjs/mods"); if (!fs.existsSync(__dirname + "/svrjs/mods")) fs.mkdirSync(__dirname + "/svrjs/mods");
console.log("Deleting SVR.JS stub..."); console.log("Deleting SVR.JS stub...");
fs.unlinkSync(__dirname + "/svrjs/svr.js"); fs.unlinkSync(__dirname + "/svrjs/svr.js");
// Modules aren't extracted in SVR.JS's 4.x stub, so no module extraction code here. // Modules aren't extracted in SVR.JS's 4.x stub, so no module extraction code here.