Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.9k views
in Technique[技术] by (71.8m points)

shell - 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 development.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...