marp-team / marp-cli

A CLI interface for Marp and Marpit based converters
MIT License
1.85k stars 105 forks source link

Marp and inotifywait #563

Closed nkpap closed 9 months ago

nkpap commented 9 months ago

Hi all, I try to run the following bash script but it doesn't create any pdf. However if the invoked command is marp --version it is executed. The same applies if the command to be executed is cp $FILE $FILE.pdf excluding any file permission issues.

#!/bin/bash

# Use inotifywait in a loop
inotifywait -m -e modify --format '%w%f' *.md | while read FILE
do
  echo "Changed file: $FILE and ${FILE%.md}.pdf"
# command
  marp $FILE  -o ${FILE%.md}.pdf
done

Am I missing something? Thank you

yhatt commented 9 months ago

Try to add --no-stdin option.

marp --no-stdin $FILE -o ${FILE%.md}.pdf

If Marp CLI detected opening stdin stream, Marp CLI tries to read stdin as Markdown contents and waits to close it. In the case you've provided, inotifywait -m looks like not to close the stdin stream so CLI would not begin the conversion.

nkpap commented 9 months ago

Hi Yuki, Thank you it works like a charm! It makes sense now. BR Nikos