Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat the environment during webpack build as browser rather than node #61

Merged
merged 1 commit into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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