File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 22
33var queryString = require ( "qs" ) ;
44var 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 ) ,
You can’t perform that action at this time.
0 commit comments