I'm trying to setup my web-app (browser extension) so that I can seamlessly move between development, test and production. For the most part I've avoided hardcoding any URLs into the app, but there are few places where this isn't possible:
- As a browser extension that injects js, I can't use relative paths (or location.host) when inserting an iframe on a page since it'll default to the domain it's being inserted on. (but I infact need this to be localhost for testing and then www.mydomain.com once I push live)
- I also sometimes like to test against both the test and live database, but don't want to have to always toggle that flag and risk committing the test db settings.
What's I'd really like to do is a search/replace before I commit (on a couple of files x.php, y.js) to swap out localhost with www.mydomain.com.
Can anyone tell me how to do that with a precommit hook (or any other technique)?
EDIT:
While I have this posted under mercurial hooks -- I'm 100% open to any other method of automating the changes...
- I'm be OK with doing the change on the live server after pulling changes as well ..
- I guess for the DB changes, I could just remove the config file from my repo and keep a preconfig version on my live server -- but I don't love this because pulling from my repo to a new server / path would pull the entire app without any db settings... (just dumping my ideas here in case it helps someone with a solution)
Thanks!