From 86359660b2db269f7d6d4728aabb50889f08de41 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Sat, 22 Jul 2023 06:40:28 +0200 Subject: [PATCH] Complain on errors --- lib/build-pdf.js | 22 +++++++++------------- lib/build.js | 10 ++-------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lib/build-pdf.js b/lib/build-pdf.js index 82f89f7e..ffc01aa7 100644 --- a/lib/build-pdf.js +++ b/lib/build-pdf.js @@ -1,8 +1,6 @@ const pdf = require("./pdf.js"); const fs = require("fs"); -let errors = false; - fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( doc ) { @@ -14,17 +12,15 @@ fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( const pdfStat = fs.statSync(pdfFile, { throwIfNoEntry: false }); if (pdfStat === undefined || htmlStat?.mtime > pdfStat?.mtime) { - console.log(doc.name); - - pdf(doc.name).catch((error) => { - console.error(error); - errors = true; - }); + pdf(doc.name) + .then(() => { + console.log("✓ " + doc.name); + }) + .catch((error) => { + console.log("❌ " + doc.name); + console.error(error); + process.exitCode = 1; + }); } } }); - -//TODO: needs to await all threads -// if (errors) { -// process.exit(1); -// } diff --git a/lib/build.js b/lib/build.js index e739d02e..00bc66ea 100644 --- a/lib/build.js +++ b/lib/build.js @@ -3,8 +3,6 @@ const pandoc = require("./pandoc"); const fs = require("fs"); const { PassThrough } = require("stream"); -let errors = false; - fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( doc ) { @@ -37,14 +35,10 @@ fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function ( console.log("✓ " + doc.name); }) .catch((err) => { + console.log("❌ " + doc.name); console.error(err.join("\n")); console.error(); - errors = true; + process.exitCode = 1; }); } }); - -//TODO: needs to await all threads -// if (errors) { -// process.exit(1); -// }