Skip to content

Commit

Permalink
[BUGFIX] fix live-reloading post build error
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanpenner committed Jan 13, 2016
1 parent 2e06a8e commit beb2171
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/tasks/server/livereload-server.js
Expand Up @@ -132,12 +132,18 @@ module.exports = Task.extend({

didChange: function(results) {
var previousTree = this.tree;
this.tree = new FSTree.fromEntries(this.getDirectoryEntries(results.directory));
var files;

var files = previousTree.calculatePatch(this.tree)
.filter(isNotDirectory)
.map(relativePath)
.filter(isNotSourceMapFile);
if (results.directory) {
this.tree = new FSTree.fromEntries(this.getDirectoryEntries(results.directory));
files = previousTree.calculatePatch(this.tree)
.filter(isNotDirectory)
.map(relativePath)
.filter(isNotSourceMapFile);

} else {
files = ['LiveReload files'];
}

debug('files %a', files);

Expand Down
27 changes: 27 additions & 0 deletions tests/unit/tasks/server/livereload-server-test.js
Expand Up @@ -331,6 +331,33 @@ describe('livereload-server', function() {

expect(reloadedFiles).to.deep.equal(expectedResult);
});

it('triggers livereload with "LiveReload files" if no results.directory was provided', function() {
var changedFiles = [
'assets/my-project.css',
'assets/my-project.css.map'
];

var expectedResult = [
'assets/my-project.css'
];
var changedOptions;
subject.liveReloadServer = function() {
return {
changed: function(options) {
changedOptions = options;
}
};
};

subject.didChange({});

expect(changedOptions).to.deep.equal({
body: {
files: ['LiveReload files']
}
});
});
});
});
});

0 comments on commit beb2171

Please sign in to comment.