From 7bba6cbde6743c88d038cb0adfbbfe6ac3b32b3c Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Wed, 21 Oct 2020 21:38:24 +0200 Subject: [PATCH] Add basic error check in build_mod.js Check if the additional file to add exists before trying to pack it. Note that there may be other ways reading the files could break, but this should suffice for most cases of getting it wrong. --- packages/lib/build_mod.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/lib/build_mod.js b/packages/lib/build_mod.js index 4be597a1..ffe54f83 100644 --- a/packages/lib/build_mod.js +++ b/packages/lib/build_mod.js @@ -79,6 +79,9 @@ async function build(args) { for (let pathParts of info.additional_files || []) { let filePath = path.join(args.sourceDir, ...pathParts); + if (!await fs.pathExists(filePath)) { + throw new Error(`Additional file ${filePath} does not exist`); + } zip.file(path.posix.join(modName, path.basename(filePath)), fs.createReadStream(filePath)); } delete info.additional_files;