Skip to content

Commit

Permalink
Merge pull request #61 from carlobeltrame/master
Browse files Browse the repository at this point in the history
Treat the environment during webpack build as browser rather than node
  • Loading branch information
jamesdbloom authored Oct 30, 2020
2 parents 57c8ed2 + da1fa15 commit 32531f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mockServerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ var mockServerClient;
(function () {
"use strict";

runningInNode = function () {
return (typeof require !== 'undefined') && require('browser-or-node').isNode
}

/**
* Start the client communicating at the specified host and port
* for example:
Expand All @@ -24,7 +28,7 @@ var mockServerClient;
*/
mockServerClient = function (host, port, contextPath, tls, caCertPemFilePath) {

var makeRequest = (typeof require !== 'undefined' ? require('./sendRequest').sendRequest(tls, caCertPemFilePath) : function (host, port, path, jsonBody, resolveCallback) {
var makeRequest = (runningInNode() ? require('./sendRequest').sendRequest(tls, caCertPemFilePath) : function (host, port, path, jsonBody, resolveCallback) {
var body = (typeof jsonBody === "string" ? jsonBody : JSON.stringify(jsonBody || ""));
var url = (tls ? 'https' : 'http') + '://' + host + ':' + port + path;

Expand Down Expand Up @@ -171,7 +175,7 @@ var mockServerClient;
};
};

var WebSocketClient = (typeof require !== 'undefined' ? require('./webSocketClient').webSocketClient(tls, caCertPemFilePath) : function (host, port, contextPath) {
var WebSocketClient = (runningInNode() ? require('./webSocketClient').webSocketClient(tls, caCertPemFilePath) : function (host, port, contextPath) {
var clientId;
var clientIdHandler;
var requestHandler;
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"gruntplugin"
],
"dependencies": {
"browser-or-node": "^1.3.0",
"grunt-ts": "^6.0.0-beta.22",
"q": "~2.0",
"websocket": "^1.0.30"
Expand Down

0 comments on commit 32531f4

Please sign in to comment.