0

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!

  • When asking about hooks it is useful to specify what operating system you're using it on so that people know what scripting language to use. – Steve Kaye May 18 '13 at 12:48
  • Thanks: My dev environment is Windows 7 (IIS), using mimosajs to go between dev and test and then I'm using Kiln for source control. On the production side I'm running an Ubuntu server with mercurial. – user2197645 May 18 '13 at 16:56

1 Answers1

0

I'd put something in a file that is not under version control (i.e. add it to your .hgignore). Make something fail obnoxiously if the file is not there (or pick a sane default), and you can now easily switch the hostname in that file (without risking committing it).

djc
  • 11,603
  • 5
  • 41
  • 54