Skip to content

Commit

Permalink
Complain on errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfhandl committed Jul 22, 2023
1 parent 6517a56 commit 8635966
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
22 changes: 9 additions & 13 deletions lib/build-pdf.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const pdf = require("./pdf.js");
const fs = require("fs");

let errors = false;

fs.readdirSync(__dirname + "/..", { withFileTypes: true }).forEach(function (
doc
) {
Expand All @@ -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);
// }
10 changes: 2 additions & 8 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down Expand Up @@ -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);
// }

0 comments on commit 8635966

Please sign in to comment.