Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return fs.readdir(htmlRepliesPath, (err, files) => {
if (err)
return done(err);
// Iterate on the files we found.
return async.eachSeries(files, (file, nextFile) => {
// Read the file.
return fs.readFile(path.join(htmlRepliesPath, file), "utf-8", (err, html) => {
if (err)
return nextFile(err);
const replyHtml = quotations.extractFromHtml(html).body;
const replyPlain = utils.htmlToText(replyHtml);
assert.equal(
removeWhitespace("Hi. I am fine.\n\nThanks,\nAlex"),
removeWhitespace(replyPlain));
return nextFile();
});
}, done);
return fs.readdir(standardRepliesPath, function (err, files) {
if (err)
return done(err);
// Iterate on the files we found.
return async.eachSeries(files, (file, nextFile) => {
// We're only interested in email files.
if (file.substr(-4) !== ".eml")
return nextFile();
return async.series({
// Parse the EML file.
emailText: next => utils.parseEmlText(path.join(standardRepliesPath, file), next),
// Try and load the reply text for this message.
replyText: next => utils.tryReadFile(path.join(standardRepliesPath, file.slice(0, -4) + "_reply_text"), next),
// Compare the results.
checkText: (next, results) => {
// Try and extract the reply from the loaded message.
const extractedText = quotations.extractFromPlain(results.emailText).body;