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.
This commit is contained in:
Hornwitser committed 2020-10-21 21:38:24 +02:00
1 parent b2408d54ec
commit 7bba6cbde6
1 file changed
+3
+3
View File
@@ -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;