Skip to content
Browse files

Merge pull request #1 from speier/master

Added support for Windows
  • Loading branch information...
2 parents 51c425b + 1f7f6a3 commit a05383e4344d8172f104531dc18f9b4f5134648c @jed committed
Showing with 9 additions and 7 deletions.
  1. +1 −1 cli.js
  2. +6 −4 lib/localhose.js
  3. +2 −2 test.js
View
2 cli.js
@@ -1,6 +1,6 @@
#!/usr/bin/env node
-var localhose = require( "localhose" )
+var localhose = require( "./lib/localhose" )
, method = process.argv[ 2 ]
, args = process.argv.slice( 3 )
View
10 lib/localhose.js
@@ -1,11 +1,13 @@
var fs = require( "fs" )
+ , path = require( "path" )
, exec = require( "child_process" ).exec
, Localhoses = function(){}
-
-if ( process.platform != "darwin" ) throw "Sorry, only tested on OS X."
-
+ , platform = process.platform
+
+if ( platform != "darwin" && platform != "win32" ) throw "Sorry, only tested on OS X and Windows."
+
Localhoses.prototype = {
- hostsPath: "/private/etc/hosts",
+ hostsPath: ( platform == "darwin" ) ? "/private/etc/hosts" : path.join(process.env["WinDir"], "System32", "drivers", "etc", "hosts"),
header:
"# <localhose>",
View
4 test.js
@@ -8,7 +8,7 @@
var assert = require( "assert" )
, http = require( "http" )
- , localhose = require( "localhose" ).unset()
+ , localhose = require( "./lib/localhose" ).unset()
, url = require( "url" ).parse( "http://nodejs.org/" )
, sassyTitle = "rYah'S aweSOmE homEpagE!"
@@ -63,6 +63,6 @@ function getTitle( uri, cb ) {
http.get( url, function( res ) {
res
.on( "data", function( data ){ body += data } )
- .on( "end", function(){ cb( ( /<title>([^<]+)/( body ) || [] )[ 1 ] ) } )
+ .on( "end", function(){ cb( ( /<title>([^<]+)/.exec( body ) || [] )[ 1 ] ) } )
})
}

0 comments on commit a05383e

Please sign in to comment.
Something went wrong with that request. Please try again.