Skip to content

Commit

Permalink
Stop browser:reload, file:reload and stream:changed events from loggi…
Browse files Browse the repository at this point in the history
…ng, if "logFileChanges" is false.
  • Loading branch information
dsc authored and shakyShane committed Apr 25, 2015
1 parent f4447bf commit 86191d9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
3 changes: 0 additions & 3 deletions lib/file-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ var fileUtils = {
*/
if (data.event === "change") {
if (!bs.paused && data.namespace === "core") {
if (_.isUndefined(data.log)) {
data.log = bs.options.get("logFileChanges");
}
bs.events.emit("file:reload", fileUtils.getFileInfo(data, bs.options));
}
}
Expand Down
23 changes: 13 additions & 10 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports.callbacks = {
* @param data
*/
"file:reload": function (bs, data) {
if (data.log) {
if (bs.options.get("logFileChanges")) {

if (data.path[0] === "*") {
return logger.info("{cyan:Reloading files that match: {magenta:%s", data.path);
Expand All @@ -63,8 +63,10 @@ module.exports.callbacks = {
/**
*
*/
"browser:reload": function () {
logger.info("{cyan:Reloading Browsers...");
"browser:reload": function (bs) {
if (bs.getOption("logFileChanges")) {
logger.info("{cyan:Reloading Browsers...");
}
},
/**
* @param {BrowserSync} bs
Expand All @@ -78,14 +80,15 @@ module.exports.callbacks = {
* @param data
*/
"stream:changed": function (bs, data) {
if (bs.getOption("logFileChanges")) {
var changed = data.changed;

var changed = data.changed;

logger.info("{cyan:%s %s changed} ({magenta:%s})",
changed.length,
changed.length > 1 ? "files" : "file",
changed.join(", ")
);
logger.info("{cyan:%s %s changed} ({magenta:%s})",
changed.length,
changed.length > 1 ? "files" : "file",
changed.join(", ")
);
}
},
/**
* Client connected logging
Expand Down
12 changes: 0 additions & 12 deletions test/specs/e2e/files/e2e.file.changed.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,6 @@ describe("E2E Responding to events", function () {
assert.isFalse(instance.paused);
});

it("Sets `log: false` if `log` is undefined in event", function () {

// Emit the event as it comes from the file-watcher
instance.events.emit("file:changed", {path: "styles.css", event: "change", namespace: "core"});

clock.tick();

var args = socketsStub.getCall(0).args[1];

assert.isTrue(args.log);
});

it("fires the browser:reload event to the browser", function () {

// Emit the event as it comes from the file-watcher
Expand Down

0 comments on commit 86191d9

Please sign in to comment.