Skip to content

Commit

Permalink
add delay option in case of longer builds (#38)
Browse files Browse the repository at this point in the history
* add delay option in case of longer builds

* update readme with delay param
  • Loading branch information
marcelkalveram authored and statianzo committed Oct 29, 2017
1 parent f5b88ca commit c5b6ae7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Add a script tag to your page pointed at the livereload server
automatically to `<head>`.
- `ignore` - (Default: `null`) RegExp of files to ignore. Null value means
ignore nothing.
- `delay` - (Default: `0`) amount of milliseconds by which to delay the live reload (in case build takes longer)

## Why?

Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ function LiveReloadPlugin(options) {
this.ignore = this.options.ignore || null;
this.quiet = this.options.quiet || false;

// add delay, but remove it from options, so it doesn't get passed to tinylr
this.delay = this.options.delay || 0;
delete this.options.delay;

this.lastHash = null;
this.lastChildHashes = [];
this.protocol = this.options.protocol ? this.options.protocol + ':' : '';
Expand Down Expand Up @@ -61,7 +65,7 @@ LiveReloadPlugin.prototype.done = function done(stats) {
this.lastChildHashes = childHashes;
setTimeout(function onTimeout() {
this.server.notifyClients(include);
}.bind(this));
}.bind(this), this.delay);
}
};

Expand Down

0 comments on commit c5b6ae7

Please sign in to comment.