Skip to content

Commit

Permalink
fix(http-protocol): enable notify command over http - closes #1467
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane committed Dec 19, 2017
1 parent a069c04 commit ac86665
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/http-protocol.js
Expand Up @@ -2,6 +2,17 @@

var queryString = require("qs");
var proto = exports;
var instanceMethods = ["exit", "notify", "pause", "resume"];

/**
* Does the requested method expect an instance of BrowserSync
* or raw access to the emitter?
* @param method
* @returns {boolean}
*/
function methodRequiresInstance(method) {
return instanceMethods.indexOf(method) > -1;
}

/**
* Use BrowserSync options + querystring to create a
Expand Down Expand Up @@ -48,7 +59,11 @@ proto.middleware = function (bs) {

try {

require("./public/" + params.method)(bs.events).apply(null, [params.args]);
var bsOrEmitter = methodRequiresInstance(params.method)
? bs
: bs.events;

require("./public/" + params.method)(bsOrEmitter).apply(null, [params.args]);

output = [
"Called public API method `.%s()`".replace("%s", params.method),
Expand Down

0 comments on commit ac86665

Please sign in to comment.