Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for partial not found error on windows due to glob.sync #906

Closed
damdafayton opened this issue Nov 16, 2022 · 5 comments
Closed

Fix for partial not found error on windows due to glob.sync #906

damdafayton opened this issue Nov 16, 2022 · 5 comments

Comments

@damdafayton
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @nestjs-modules/mailer@1.8.1 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/@nestjs-modules/mailer/dist/adapters/handlebars.adapter.js b/node_modules/@nestjs-modules/mailer/dist/adapters/handlebars.adapter.js
index b42eee5..76a76c1 100644
--- a/node_modules/@nestjs-modules/mailer/dist/adapters/handlebars.adapter.js
+++ b/node_modules/@nestjs-modules/mailer/dist/adapters/handlebars.adapter.js
@@ -29,6 +29,7 @@ class HandlebarsAdapter {
                 ? path.dirname(template)
                 : path.join((0, lodash_1.get)(options, 'dir', ''), path.dirname(template));
             const templatePath = path.join(templateDir, templateName + templateExt);
+            
             if (!this.precompiledTemplates[templateName]) {
                 try {
                     const template = fs.readFileSync(templatePath, 'utf-8');
@@ -51,7 +52,9 @@ class HandlebarsAdapter {
             data: {},
         });
         if (runtimeOptions.partials) {
-            const files = glob.sync(path.join(runtimeOptions.partials.dir, '**', '*.hbs'));
+            const partialPath=path.join(runtimeOptions.partials.dir, '**', '*.hbs').replace(/\\/g,'/');
+            
+            const files = glob.sync(partialPath);
             files.forEach((file) => {
                 const { templateName, templatePath } = precompile(file, () => { }, runtimeOptions.partials);
                 const templateDir = path.relative(runtimeOptions.partials.dir, path.dirname(templatePath));

This issue body was partially generated by patch-package.

@KybalionX
Copy link

That's amazing! I've been trying to solve this issue in a different ways, but this is the only one that work for me (Windows user)

@adamrehill
Copy link

adamrehill commented Feb 7, 2023

Thanks for this! saved me a ton of time digging! Created a PR here: #951

@Prooksius
Copy link

Thanks for the tip. Everything works fine now.
But unfortunately when installing the package from npm, it is old, without this fix. Pls update.

@francobasilico
Copy link

WHen is this going to be deployed?

@fendermany
Copy link

fendermany commented Aug 3, 2023

Fixed by ^1.9.1

@juandav juandav closed this as completed Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants