From dec0a3b3e5de9c99dd9e066aa63e596c6a9ac96c Mon Sep 17 00:00:00 2001 From: Davy Dequidt <3024137+ddequidt@users.noreply.github.com> Date: Fri, 16 May 2025 17:29:14 +0200 Subject: [PATCH] #468 fix DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake. --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index e012f41..3972876 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ const getPaths = require('get-paths'); const { convert } = require('html-to-text'); const juice = require('juice'); const nodemailer = require('nodemailer'); +const { isPromise } = require('util/types'); let previewEmail; @@ -251,7 +252,11 @@ class Email { if (locale !== locals.locale) i18n.setLocale(locals.locale); } - const res = await util.promisify(renderFn)(filePath, locals); + const res = await (isPromise( + Reflect.apply(renderFn, this, [filePath, locals]) + ) + ? renderFn(filePath, locals) + : util.promisify(renderFn)(filePath, locals)); // transform the html with juice using remote paths // google now supports media queries // https://developers.google.com/gmail/design/reference/supported_css