Permalink
Browse files

Added a commandline utility

First pass at a command line program to start
the server and watch files, based on a patch
from Marc Harter.
  • Loading branch information...
1 parent b89c5d7 commit 3c32b62a9fbe4047e850ec7f18fc596311cf1e91 @napcs committed Jun 9, 2012
Showing with 70 additions and 15 deletions.
  1. +2 −3 Cakefile
  2. +0 −9 bin.js
  3. +3 −0 bin/livereload.js
  4. +28 −0 lib/command.coffee
  5. +33 −0 lib/command.js
  6. 0 { → lib}/livereload.coffee
  7. 0 { → lib}/livereload.js
  8. +4 −3 package.json
View
@@ -1,6 +1,5 @@
-{print} = require 'util'
{spawn} = require 'child_process'
task 'build', 'Build CoffeeScript source files', ->
- coffee = spawn 'coffee', ['-cw', 'livereload.coffee']
- coffee.stdout.on 'data', (data) -> print data.toString()
+ coffee = spawn 'coffee', ['-cw', 'lib']
+ coffee.stdout.on 'data', (data) -> console.log data.toString().trim()
View
9 bin.js
@@ -1,9 +0,0 @@
-#!/usr/bin/env node
-
-var resolve = require('path').resolve
-var path = resolve(process.argv[2] || '.')
-var livereload = require('./livereload')
-var server = livereload.createServer({debug: true})
-
-server.watch(path)
-console.log('live reloading ' + path)
View
@@ -0,0 +1,3 @@
+#!/usr/bin/env node
+require('../lib/command').run();
+
View
@@ -0,0 +1,28 @@
+runner = ->
+
+ livereload = require './livereload'
+ resolve = require('path').resolve
+ opts = require 'opts'
+
+ opts.parse [
+ {
+ short: "p"
+ long: "port"
+ description: "Specify the port"
+ value: true
+ required: false
+ }
+ ].reverse(), true
+
+ port = opts.get('port') || 35729
+
+ server = livereload.createServer({port: port, debug: true})
+
+ path = resolve(process.argv[2] || '.')
+
+ console.log('Starting LiveReload for ' + path)
+
+ server.watch(path)
+
+module.exports =
+ run: runner
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
File renamed without changes.
File renamed without changes.
View
@@ -1,6 +1,6 @@
{ "name": "livereload"
, "description": "LiveReload server"
-, "version": "0.3.0"
+, "version": "0.3.1"
, "contributors": [
{ "name": "Joshua Peek" }
, { "name": "Brian P. Hogan", "email": "brianhogan@napcs.com" }
@@ -13,9 +13,10 @@
{ "type": "git"
, "url": "http://github.com/napcs/node-livereload.git"
}
-, "bin": { "livereload": "./bin.js" }
-, "main": "./livereload.js"
+, "bin": { "livereload": "./bin/livereload.js" }
+, "main": "./lib/livereload.js"
, "dependencies": {
+ "opts": ">= 1.2.0",
"websocket.io": ">= 0.1.0"
}
, "engines" : { "node" : ">=0.4.0" }

0 comments on commit 3c32b62

Please sign in to comment.