Repository: saleor/saleor

Issue:
npm run build-emails [FAILS]

### What I'm trying to achieve
I'm trying hard to install Saleor on Win10 machine for the first time and have run into a problem compile e-mails (as described in docs)

### What i do:
I have installed latest node.js and when running "npm run build-emails" i am getting the following error:
```
(Saleor) E:\Development\Web\eCommerce\saleor>npm run build-emails

> saleor@0.0.0 build-emails E:\Development\Web\eCommerce\saleor
> mkdir -p templates/templated_email/compiled/ && find templates -name "*.mjml" -not -path "templates/templated_email/source/*partials/*" -not -path "templates/templated_email/source/*shared/*" -exec mjml -l skip {} -o templates/templated_email/compiled/ \;

The syntax of the command is incorrect.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! saleor@0.0.0 build-emails: `mkdir -p templates/templated_email/compiled/ && find templates -name "*.mjml" -not -path "templates/templated_email/source/*partials/*" -not -path "templates/templated_email/source/*shared/*" -exec mjml -l skip {} -o templates/templated_email/compiled/ \;`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the saleor@0.0.0 build-emails script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ilja\AppData\Roaming\npm-cache\_logs\2018-05-04T21_12_18_762Z-debug.log

```

This is the log file referenced in the error - [https://paste.ubuntu.com/p/snx3KS2v5d/](url)



Discussion:
Hi!

If I recall correctly, it's an issue with whether:
- the directory permissions;
- the node & npm versions;
- the Unix core commands versions.


And I'm also noting that you are using Windows and seems like, you are running the command through the Windows's msdos interpreter.


Here is an ordered checklist:
1. Can you try running this command in a bash shell? (You can get one simple to install [here](https://git-scm.com/download/win)). It will make Unix commands (`mkdir` and `find`) available for npm, it may fix the issue.
2. Make sure you are using NodeJs 8+.


I think that's it, at least in the issues I can see/ imagine for Windows.
Thank you, @NyanKiyoshi for your reply. Unfortunately, i doesn't help.
I have tried running the command both in windows msdos interpreter and in Git Bash(for windows). Using git bash i can manually create folders using "mkdir" and use "find", so that's not a problem. Once I navigate to the saleor dir and run 'npm run build-emails' it shows me the same error. 
```
Ilja@IAP-Leiko MINGW64 /e/Development/Web/eCommerce/saleor (master)
$ npm run build-emails

> saleor@0.0.0 build-emails E:\Development\Web\eCommerce\saleor
> mkdir -p templates/templated_email/compiled/ && find templates -name "*.mjml" -not -path "templates/templated_email/source/*partials/*" -not -path "templates/templated_email/source/*shared/*" -exec mjml -l skip {} -o templates/templated_email/compiled/ \;

The syntax of the command is incorrect.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! saleor@0.0.0 build-emails: `mkdir -p templates/templated_email/compiled/ && find templates -name "*.mjml" -not -path "templates/templated_email/source/*partials/*" -not -path "templates/templated_email/source/*shared/*" -exec mjml -l skip {} -o templates/templated_email/compiled/ \;`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the saleor@0.0.0 build-emails script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Ilja\AppData\Roaming\npm-cache\_logs\2018-05-05T06_33_24_699Z-debug.log

```
And from the log file autocreated i can see that my versions to be:
```
2 info using npm@5.6.0
3 info using node@v8.11.1
```
Okay! If you managed to run the command from the shell, it's already that taken, since it means you managed to build the emails. 
Just need to figure what is triggering the error on `npm`'s side. I'm gonna be off to work soon, so I will be able to take a look from the environment where I had this same issue, which I did manage to fix, but I'm not sure anymore how I did it, and what was my final conclusion on the issue. I will keep you updated.
The problem is that the `build-emails` script relies on POSIX commands `mkdir` and `find`. They are not available on Windows. Even if you execute `npm` from a bash shell you are likely executing the Windows build of `npm` which internally executes the script using the regular Windows kernel calls (which I think nowadays uses PowerShell).

The proper solution would be not to rely on POSIX tools in the script (essentially reimplement it using JS or Python).

Resolving patch:
diff --git a/saleor/account/emails.py b/saleor/account/emails.py
--- a/saleor/account/emails.py
+++ b/saleor/account/emails.py
@@ -14,7 +14,7 @@ def send_password_reset_email(context, recipient):
             kwargs={'uidb64': context['uid'], 'token': context['token']}))
     context['reset_url'] = reset_url
     send_templated_mail(
-        template_name='source/account/password_reset',
+        template_name='account/password_reset',
         from_email=settings.DEFAULT_FROM_EMAIL,
         recipient_list=[recipient],
         context=context)
diff --git a/saleor/dashboard/emails.py b/saleor/dashboard/emails.py
--- a/saleor/dashboard/emails.py
+++ b/saleor/dashboard/emails.py
@@ -20,7 +20,7 @@ def send_set_password_email(staff):
         'uid': urlsafe_base64_encode(force_bytes(staff.pk)).decode(),
         'token': default_token_generator.make_token(staff)}
     send_templated_mail(
-        template_name='source/dashboard/staff/set_password',
+        template_name='dashboard/staff/set_password',
         from_email=settings.DEFAULT_FROM_EMAIL,
         recipient_list=[staff.email],
         context=ctx)
@@ -35,7 +35,7 @@ def send_promote_customer_to_staff_email(staff):
         'url': build_absolute_uri(reverse('dashboard:index')),
         'site_name': site.name}
     send_templated_mail(
-        template_name='source/dashboard/staff/promote_customer',
+        template_name='dashboard/staff/promote_customer',
         from_email=settings.DEFAULT_FROM_EMAIL,
         recipient_list=[staff.email],
         context=ctx)
diff --git a/saleor/order/emails.py b/saleor/order/emails.py
--- a/saleor/order/emails.py
+++ b/saleor/order/emails.py
@@ -8,11 +8,11 @@
 from ..seo.schema.email import get_order_confirmation_markup
 from .models import Fulfillment, Order
 
-CONFIRM_ORDER_TEMPLATE = 'source/order/confirm_order'
-CONFIRM_FULFILLMENT_TEMPLATE = 'source/order/confirm_fulfillment'
-UPDATE_FULFILLMENT_TEMPLATE = 'source/order/update_fulfillment'
-CONFIRM_PAYMENT_TEMPLATE = 'source/order/payment/confirm_payment'
-CONFIRM_NOTE_TEMPLATE = 'source/order/note/confirm_note'
+CONFIRM_ORDER_TEMPLATE = 'order/confirm_order'
+CONFIRM_FULFILLMENT_TEMPLATE = 'order/confirm_fulfillment'
+UPDATE_FULFILLMENT_TEMPLATE = 'order/update_fulfillment'
+CONFIRM_PAYMENT_TEMPLATE = 'order/payment/confirm_payment'
+CONFIRM_NOTE_TEMPLATE = 'order/note/confirm_note'
 
 
 def get_email_context(order_token):


Test patch:
diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.py
--- a/tests/dashboard/test_staff.py
+++ b/tests/dashboard/test_staff.py
@@ -105,7 +105,7 @@ def test_send_set_password_email(staff_user, site_settings):
         'uid': urlsafe_base64_encode(force_bytes(staff_user.pk)).decode(),
         'token': default_token_generator.make_token(staff_user)}
     send_templated_mail(
-        template_name='source/dashboard/staff/set_password',
+        template_name='dashboard/staff/set_password',
         from_email=DEFAULT_FROM_EMAIL,
         recipient_list=[staff_user.email],
         context=ctx)