Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit d12ec432b6b404e912a6aa21aa99c6905b749abf @jgallen23 committed Dec 11, 2012
Showing with 1,149 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +19 −0 README.md
  3. +53 −0 index.js
  4. +21 −0 package.json
  5. +1,055 −0 support/livereload.js
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1,19 @@
+#reloadr
+
+A very simple LiveReload server that watches the current directory for file changes.
+
+##Install
+
+```
+npm install -g reloadr
+```
+
+##Usage
+
+Just run `reloadr` in the directory that you want to watch for file changes and then start the [LiveReload extension](http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-)
+
+##Todo
+
+- Pass in folder to watch
+- Only watch certain extensions
+
@@ -0,0 +1,53 @@
+#!/usr/bin/env node
+
+var LRServer = require('livereload-server');
+var fs = require('fs');
+var path = require('path');
+var gaze = require('gaze');
+
+//LiveReload server
+var server = new LRServer({ id: 'com.jga.reloadr', name: 'Reloadr', version: '1.0', protocols: { monitoring: 7, saving: 1 }});
+server.on('connected', function() {
+ console.log('client connected');
+});
+
+server.on('livereload.js', function(request, response) {
+ console.log("Serving livereload.js.");
+ fs.readFile(path.join(__dirname, 'support/livereload.js'), 'utf8', function(err, data) {
+ if (err) throw err;
+
+ response.writeHead(200, {'Content-Length': data.length, 'Content-Type': 'text/javascript'});
+ response.end(data);
+ });
+});
+
+server.listen(function(err) {
+ if (err) {
+ throw err;
+ }
+ console.log('Server Started');
+});
+
+var refresh = function(filepath) {
+ for (var key in server.connections) {
+ var conn = server.connections[key];
+ try {
+ conn.send({
+ command: 'reload',
+ path: filepath,
+ liveCSS: true
+ });
+ } catch(e) {
+ //console.log('error', e.message);
+ }
+ }
+};
+
+
+//watcher
+gaze('**/*', function(err, watcher) {
+ this.on('all', function(event, filepath) {
+ console.log('File changed: '+ filepath);
+ refresh(filepath);
+ });
+});
@@ -0,0 +1,21 @@
+{
+ "name": "reloadr",
+ "description": "livereload cli tool",
+ "homepage": "https://github.com/jgallen23/reloadr",
+ "author": "Greg Allen <@jgaui> (http://jga.me)",
+ "version": "0.0.1",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/jgallen23/reloadr.git"
+ },
+ "dependencies": {
+ "gaze": "~0.2.2",
+ "livereload-server": "~0.2.1"
+ },
+ "devDependencies": {},
+ "main": "./index.js",
+ "scripts": {},
+ "bin": {
+ "reloadr": "index.js"
+ }
+}
Oops, something went wrong.

0 comments on commit d12ec43

Please sign in to comment.