DEPRECATED: use local-tld instead
Hose your hosts file for easier local web development
Want to see pretty graphs? Log in now!
npm install localhose
|4||downloads in the last month|
|Last Published By|
|Version||0.1.5 last updated a year ago|
Localhose is a node.js module that provides a simple API for dynamically adding hosts to the
/etc/hosts file, to fool your web browser into thinking
anydomain.com points to your local machine. This makes web development easier, since the local build and production build can now use identical URLs.
WARNING: This software requires superuser access, and will temporarily overwrite your hosts file. If you do not understand what that means, it's probably not a good tool for you.
- node.js, tested with 0.4.1
- OS X, version 10.5 or later (soon, any OS with a
- superuser access to your machine
$ npm install localhose
localhose = require( "localhose" )
Returns a global
localhose object that keeps track of what domains are being rerouted.
localhose.set( host1, [host2], [etc] )
Adds one or more hosts to be routed to your local machine. The hosts are stored within the existing hosts file, like this:
# <localhose> # The following have been added temporarily by Localhose # For more information, see https://github.com/jed/localhose 127.0.0.1 yourdomain.com 127.0.0.1 yourdomain.net # </localhose>
The path of the host file can be specified using the
hostsPath property of the
localhose.unset( [host1], [host2], [etc] )
Removes some or all of the hosts rerouted to your machine. If no arguments are specified, all currently hosts are unset. If no hosts remain after this is called, the
# <localhose> ... # </localhose> section of the current
hosts file is removed, leaving your file system as pristine as it was before.
Returns a list of domains currently being rerouted to
$ sudo localhose set host1 [host2] [etc]
localhose.set, but for the command line.
$ sudo localhose unset [host1] [host2] [etc]
localhose.unset, but for the command line.
For an example rerouting
nodejs.org to your machine, see test.js. Otherwise, usage is basically like this:
// sudo node ./someFile.js localhose = require( "localhose" ) // resolve "google.com" and "google.org" to 127.0.0.1. // note that you will be unable to use google while this is set. localhose.set( "google.com", "google.org" ) localhose.domains() // [ "google.com", "google.org" ] // remove all domains, and revert the `hosts` file to its original state localhose.unset( "google.com" )
- Add support for non-OS X systems if anyone's interested.
Copyright (c) 2011 Jed Schmidt. See LICENSE.txt for details.
Send any questions or comments here.