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
525 views
in Technique[技术] by (71.8m points)

testing - Automatically refresh browser in response to file system changes?

When doing web development, you frequently make changes and then refresh the browser. Is there an easy way to have a daemon listening for changes in the filesystem, and when there is one, to send a refresh message to Firefox or Safari?

This would really improve your workflow and focus. You could keep your browser running in a separate screen, and when you're working on UI related changes, it would automatically refresh as you're working.

It would be like using autotest when doing TDD. (See http://github.com/svoop/autotest-fsevent)

Has anybody done this?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

I can think of a way to do this for Firefox. You install the MozRepl plugin. You can then have it start up and telnet to port 4242 (by default) and control the browser via. Javascript commands. Issuing a BrowserReload() will reload the current tab.

Now, add an editor hook to do that when any files in the current project are saved and it'll be taken care of. I believe there are some snippets around that already do this.

I don't use Safari or Chrome too much so I don't know about options there.

Also, I'm not sure this is a good idea really. I don't want my browser to refresh on every file save. I usually make a bunch of changes to the backend, css and maybe even images and then when I'm ready, reload the browser tab. It's not per save. Anyway, this will do what you want.


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

...