Skip to content

Commit

Permalink
example: rework express example to use gaze
Browse files Browse the repository at this point in the history
  • Loading branch information
mklabs committed Oct 15, 2016
1 parent 2f3db7f commit 2dad1b2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
src*
tiny-lr.pid
.tern-port
11 changes: 5 additions & 6 deletions examples/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const path = require('path');
const express = require('express');
const tinylr = require('../..');
const debug = require('debug')('tinylr:server');
const gaze = require('gaze');

process.env.DEBUG = process.env.DEBUG || 'tinylr*';

Expand Down Expand Up @@ -32,14 +33,12 @@ function throttle (delay, fn) {
(function watch (em) {
em = em || new (require('events').EventEmitter)();

em.on('rename', function (file) {
tinylr.changed(file);
gaze(path.join(__dirname, 'styles/site.css'), function () {
this.on('changed', function (filepath) {
tinylr.changed(filepath);
});
});

fs.watch(path.join(__dirname, 'styles/site.css'), throttle(200, function (ev, filename) {
em.emit(ev, filename);
}));

return watch;
})();

Expand Down
4 changes: 2 additions & 2 deletions examples/express/server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const port = process.env.LR_PORT || process.env.PORT || 35729;

const debug = require('debug')('tinylr:server');

process.env.DEBUG = process.env.DEBUG || 'tinylr*';
const debug = require('debug')('tinylr:server');

const app = require('./app');

debug('Starting server');
app.listen(port, function (err) {
if (err) throw err;
debug('listening on %d', port);
Expand Down
2 changes: 1 addition & 1 deletion examples/express/styles/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body {
}

.test-lr {
padding: 2em;
padding: 4em;
color: #444;
/* color: red; */
font-weight: bolder;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"eslint-plugin-promise": "^1.1.0",
"eslint-plugin-standard": "^1.3.2",
"express": "^4.1.1",
"gaze": "^1.1.2",
"make": "^0.8.1",
"mocha": "^2.3.3",
"standard-version": "^2.2.1",
Expand Down

0 comments on commit 2dad1b2

Please sign in to comment.