Skip to content

Commit ac86665

Browse files
committed
fix(http-protocol): enable notify command over http - closes #1467
1 parent a069c04 commit ac86665

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/http-protocol.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
var queryString = require("qs");
44
var proto = exports;
5+
var instanceMethods = ["exit", "notify", "pause", "resume"];
6+
7+
/**
8+
* Does the requested method expect an instance of BrowserSync
9+
* or raw access to the emitter?
10+
* @param method
11+
* @returns {boolean}
12+
*/
13+
function methodRequiresInstance(method) {
14+
return instanceMethods.indexOf(method) > -1;
15+
}
516

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

4960
try {
5061

51-
require("./public/" + params.method)(bs.events).apply(null, [params.args]);
62+
var bsOrEmitter = methodRequiresInstance(params.method)
63+
? bs
64+
: bs.events;
65+
66+
require("./public/" + params.method)(bsOrEmitter).apply(null, [params.args]);
5267

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

0 commit comments

Comments
 (0)