M
M
Maxim Ivanov2016-09-26 00:08:16
bash
Maxim Ivanov, 2016-09-26 00:08:16

How to write a bash script that will listen for changes in a file?

I know that there are all sorts of task runners, but I want to do this, I wrote a bash script

#!/bin/bash

sass -t compressed build/sass/app.scss:public/css/app.css
autoprefixer-cli  -b "> 0%"  public/css/app.css -o public/css/app.css
cleancss -o public/css/app.css public/css/app.css

It executes 3 commands, but it turns out that I have to run
$ sh sass.config.sh every time
. I would like it to work as a watch, but for this it must listen for changes in the app.scss file.
How can I do this?
Or at least tell me how webpack can run this shell script after it has compiled its js (at least webpack works in watch mode there)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
index0h, 2016-09-26
@splincodewd

while true; do
    inotifywait -qq -e create,close_write,modify,move,delete $CHECK_FOLDER && $BUILD_COMMAND
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question