I'm specifically trying to simultaneously watch 2 different filetypes in 2 subdirectories:
我特意尝试同时在2个子目录中观看2种不同的文件类型:
.coffee filetypes in the 'js' subdirectory
.styl filetypes in the 'css' subdirectory
'css'子目录中'js'子目录.styl文件类型中的.coffee文件类型
I only know so much bash and I'm trying to get something like this to function
我只知道那么多bash而且我正试图让这样的东西发挥作用
while inotifywait --format %w%f ./{css,js}/*.{styl,coffee}; do
# regex pattern to match the file ending
# and define it to $ending
if[ $ending == coffee ]
then
coffee -c $file
elif[ $ending == styl ]
then
stylus -c $file
fi
done
// Edit // modified this line:
//编辑//修改了这一行:
while inotifywait --format %w%f ./{css,js}/*.{styl,coffee}; do
So now it checks both files but if there's no .coffee files on the css folder, or .styl files in js, it returns an error that no files were found.
所以现在它检查两个文件,但是如果css文件夹上没有.coffee文件,或者js中没有.styl文件,则返回错误,没有找到文件。
Additionally I noticed when I run this script, it returns/runs the following 3 times
另外我注意到当我运行这个脚本时,它返回/运行以下3次
Setting up watches.
Watches established.
./css/styles.styl
1 个解决方案
#1
3
Not the cleanest solution but works
不是最干净的解决方案,但有效
#!/bin/sh
while file=$(inotifywait -r -e modify --format "%w%f" ./); do
EXT=${file##*.}
if [ $EXT = "styl" ]
then
stylus -c $file
fi
if [ $EXT = "coffee" ]
then
coffee -c $file
fi
done
If you have a better solution that only watches the files I want, then I'm all ears
如果你有一个更好的解决方案,只能看我想要的文件,那么我全都耳朵
#1
3
Not the cleanest solution but works
不是最干净的解决方案,但有效
#!/bin/sh
while file=$(inotifywait -r -e modify --format "%w%f" ./); do
EXT=${file##*.}
if [ $EXT = "styl" ]
then
stylus -c $file
fi
if [ $EXT = "coffee" ]
then
coffee -c $file
fi
done
If you have a better solution that only watches the files I want, then I'm all ears
如果你有一个更好的解决方案,只能看我想要的文件,那么我全都耳朵