Skip to content

Commit

Permalink
Add new Individual to downloaded code
Browse files Browse the repository at this point in the history
  • Loading branch information
kohlros committed Oct 12, 2023
1 parent 22db619 commit d2b823b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions static/scripts/modules/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ async function downloadWorkspaceAsJS() {
let fileutils = await prepareFileUtils();
let plotHandler = await preparePlotting();
let gaussian = await prepareGaussian();
let individual = await prepareIndividual();
// Check if everything worked out
if (
![
Expand All @@ -47,6 +48,8 @@ async function downloadWorkspaceAsJS() {
main,
logging,
plotHandler,
gaussian,
individual,
].every((f) => f != false)
) {
alert("Something went wrong, please try again.");
Expand All @@ -65,6 +68,7 @@ async function downloadWorkspaceAsJS() {
zip.folder("modules");
zip.file("modules/fileUtils.mjs", fileutils);
zip.file("gaussian.js", gaussian);
zip.file("individual.js", individual);
let zipFile = await zip.generateAsync({ type: "blob" });
saveFile(zipFile, "elea.zip");
}
Expand Down Expand Up @@ -105,6 +109,7 @@ function prepareAlgorithm() {
`const {Handler, consolelog, saveInCSV, plot, consoleerror, Message, RecvRequest} = require("./MessageHandler.js");\n` +
`const {cpus} = require("os");\n` +
`const {gaussian} = require("./gaussian.js");\n` +
`const Individual = require("./individual.js");\n` +
`Handler.setParentPort(parentPort);\n`;

let js = getCode();
Expand Down Expand Up @@ -172,6 +177,13 @@ async function prepareGaussian() {
return code;
}

async function prepareIndividual() {
let file, code;
if (!(file = await readFile("./scripts/individual.js"))) return false;
code = file + `module.exports = Individual`;
return code;
}

function removeFirstLine(file) {
let lines = file.split("\n");
lines.shift();
Expand Down

0 comments on commit d2b823b

Please sign in to comment.