Skip to content

Commit

Permalink
Version bump – added watch patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
rc1 committed Mar 26, 2014
1 parent 906371c commit beaadc5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ _* Requests for '/' will also look for a index.jade file to compile._

-w, --watch Enable live reload
-p, --port
--watch-pattern Pattern for watching foles

### Watching pattern examples

* watch everything (default) `servant -w '/**/*'`
* watch all folders starting with a number (i.e. 0) `servant -w --watch-pattern '/[0-9]*/**/*'`

## Command line tool usage:

Expand Down
9 changes: 7 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ if (argv.h || argv.help) {
return;
}

// Options
// ## Options
var serveFromDirectory = path.resolve( argv.d || argv.dirname || path.join(__dirname, 'public/') );
var shouldWatchFiles = process.env.LIVE_RELOAD || argv.l || argv.livereload;
// Watch pattern folder
// For example
// * watch everything (default) `servant -w '/**/*'`
// * watch all folders starting with a number (i.e. 0) `servant -w --watch-pattern '/[0-9]*/**/*'`
var watchPattern = serveFromDirectory + (process.env.WATCH_PATTERN || argv['watch-pattern'] || '/**/*');
// legacy
shouldWatchFiles = shouldWatchFiles || process.env.WATCH || argv.w || argv.watch;

Expand Down Expand Up @@ -53,7 +58,7 @@ var server = http.createServer(app);
// To watch `WATCH=1 node app.js`
if (shouldWatchFiles) {
liveReload.watch({
pathPatterns: [serveFromDirectory+"/**/*"],
pathPatterns: [watchPattern],
server: server,
app: app
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "servant",
"version": "4.1.4",
"version": "4.2.0",
"private": false,
"preferGlobal": true,
"author": "Ross Cairns <r@theworkers.net>",
Expand Down

0 comments on commit beaadc5

Please sign in to comment.