sass --watch process is locking up my terminal window
I'm working on a shell script to optimize my build process on a web/front end project.
I'm using sass to enhance css development and the html5boilerplate build script to optimize for developme开发者_如何学编程nt.
I'm trying to get the script to do the following. 1. check if sass --watch is enabled, if not run
sass --watch file.scss:file.css
2. cd into the build folder and run ant build
The problem is that sass --watch locks up the terminal and the script won't step into the ant build until I hit Control-C to stop sass.
I've tried 'xterm' to spawn a new terminal window for sass, but xterm opens the X-11 app on my mac and nothing fires.
Is there another way to open a terminal window? Is there a way to thread sass? I really want to run my script and get back to a command prompt so I can repeat my command all day and keep the build process running smoothly.
This is under a Unix/Linux environment? Then try running your sass command in the background by appending the '&' (run-in-background) char. I.E.
sass --watch file.scss:file.css &
edit -- expand on what is possible for monitoring
The next level would be to make this independent of where it is started.
nohup sass --watch file.scss:file.css > ${logDir}/$(/bin/date +%Y%m%d.%H%M).sass_watch.log 2>&1 &
You can start sass --watch
and close the window, it will keep running.
Later on, if you need to check progress, you can use
tail -f ${logDir}/$(/bin/date +%Y%m%d.%H%M).sass_watch.log
To watch the current activity.
If you suspect something happened a while back, you can specify the # of lines to include in the 'scroll back', i.e.
tail -1000 -f ${logDir}/$(/bin/date +%Y%m%d.%H%M).sass_watch.log
Finally, you if your sass --watch supports some sort of time banding (stop after running 24 hrs, for example), you could make a crontab entry so you always have the --watch running AND you can always show your manager exactly what/when the system found.
edit crontab, add entry
01 00 * * * { sass --watch --time 24hrs file.scss:file.css ; } > ${logDir}/$(/bin/date +%Y%m%d.%H%M).sass_watch.log 2>&1
Crontabs are a little tricky. If you get to the point you feel you can use them, better to read the man page, other on-line help, and if you get stuck, then post on http://unix.stackexchange.com to get help.
I hope this helps.
精彩评论