1

I have installed the MJML from node package manager globally and then created a mjml filetype in PhpStorm and added a new File Watcher for MJML files with the following settings.

Name: MJML
Type: MJML from the dropdown
Program: /usr/bin/mjml
Argument: --watch $FileName$ -o $FileNameWithoutExtension$.html
Working Directory: $FileDir$

PhpStorm Version

PhpStorm 2016.3.2
Build #PS-163.10504.2, built on December 20, 2016
Licensed to PhpStorm Evaluator
Expiration date: April 3, 2017
JRE: 1.8.0_112-release-408-b6 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

For some reasons it does not watch and generate the output file.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
forethought
  • 2,913
  • 2
  • 16
  • 26
  • File Watcher gets executed on File Save event (manual or automatic) or file modification detection (e.g. file modified outside of IDE). 1) If you choose to "Show Console: Always" in that File Watcher settings -- will it be shown at all? 2) Will it run if you force re-run of File Watchers (http://stackoverflow.com/a/20012655/783119) 3) Does that file actually fits that user-created MJML File Type? 4) Some screenshots would be welcome – LazyOne Mar 08 '17 at 16:25
  • *(for reference purposes)* The same asked on PhpStorm Forums: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000117404-PhpStorm-file-watcher-does-not-watch-for-MJML-files – LazyOne Mar 08 '17 at 16:25

1 Answers1

3

Just checked - the watcher

enter image description here

does generate the output file. But you need to refresh the project manually using File | Synchronize to see the generated file, and watcher never completes.

This is the expected behavior: PhpStorm waits for exit code from a tool run as file watcher in order to refresh virtual file system. As MJML run with --watch option is kept running until you kill it, and thus doesn't return exit code when file generation completes, VFS is not auto-synchronized, and the watcher is kept running. So, the solution is to use -r instead of --watch:

-r $FileName$ -o $FileNameWithoutExtension$.html

You have already registered mjml as a watcher in PHPStorm, no need to pass --watch to it

lena
  • 90,154
  • 11
  • 145
  • 150
  • The above solution works in Mac but in Lubuntu, it does not. The problem is if I set the Mjml filetype in the File Watcher the file watcher is not starting. If I set Any it starts and generates the HTML file. – forethought Mar 09 '17 at 23:33