Make it work on nodejs 13

This commit is contained in:
2020-02-20 10:04:34 +00:00
parent ea153c6fd4
commit 3cc2c67949
3 changed files with 22 additions and 14 deletions

16
main.js
View File

@@ -289,8 +289,10 @@ db.all("select metadata from 'bookinfo'", function(err, rows) {
//var HtmlFile = path.join(os.tmpdir(), title.replace(/\s+/g, '-') + '.html');
var HtmlFile = title.replace(/\s+/g, '-') + '.html';
fs.writeFile(HtmlFile, HtmlHeader);
console.log("created the file with HTML headers.");
fs.writeFile(HtmlFile, HtmlHeader, (err) => {
if (err) throw err;
console.log("created the file with HTML headers.");
});
db.all("select id, piece, other from 'fragments' where asin='" + asin + "' order by id", function(err, rows) {
rows.forEach(function (row) {
@@ -309,11 +311,15 @@ db.all("select metadata from 'bookinfo'", function(err, rows) {
'dataUrl="' + image + '"',
'src="' + imageDataMap[image] + '"');
}
fs.appendFile(HtmlFile, uncompressedFragmentData);
fs.appendFile(HtmlFile, uncompressedFragmentData, (err) => {
if (err) throw err;
});
});
});
fs.appendFile(HtmlFile, '</body></html>');
console.log("created the file at: " + HtmlFile);
fs.appendFile(HtmlFile, '</body></html>', (err) =>{
if (err) throw err;
console.log("created the file at: " + HtmlFile);
});
});
});