Skip to content

Commit

Permalink
process exited before the promise finished, so there is no error mess…
Browse files Browse the repository at this point in the history
…age, sleep 1 second before the process exit
  • Loading branch information
Tengs Penkwe committed Feb 25, 2024
1 parent ce6a5c8 commit 2d4c05c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ function executeFile(filename: string, verbose = false) {
default:
throw new Error("Unknown result type: " + result.type);
}
process.exit(0);
// Wait for the output to finish before exiting the process
// This is necessary because the output is asynchronous
setTimeout(() => {
process.exit(0);
}, 1000);
}

interface MyArguments extends Arguments {
Expand Down
6 changes: 4 additions & 2 deletions src/backend/Farm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export class Farm {
const srcDir = "assets";
const outputConfig = this.getDisplayFarmOutputConfig(srcDir);
const outputPath = path.join(srcDir, "farm.png");

mergeImages(outputConfig.srcList, {
Canvas: Canvas,
Image: Image,
Expand All @@ -227,9 +228,10 @@ export class Farm {
}).then((b64) => {
const data = b64.split(",")[1];
const binaryData = Buffer.from(data, "base64");
fs.writeFileSync(outputPath, binaryData);

return fs.writeFileSync(outputPath, binaryData);
openImage(outputPath);
}).catch((err) => {
logger.error(`Error displaying farm: ${err}`);
});
}

Expand Down

0 comments on commit 2d4c05c

Please sign in to comment.