Skip to content

Commit

Permalink
Fixes hardcoding issue with custom port
Browse files Browse the repository at this point in the history
  • Loading branch information
m4r1vs committed Jan 14, 2018
1 parent 39c2aa8 commit f113d22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/client/components/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { readableBytes } from "../helpers/utils";
import Nav from "./nav";

import io from "socket.io-client";
const socket = io("localhost:1337");
const socket = io("localhost:" + document.location.port);

export default class Board extends Component {
state = {
Expand Down
16 changes: 13 additions & 3 deletions src/plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ const importCwd = require("import-cwd"); // used to get the users project detail
const pkg = importCwd("./package.json");

function Jarvis(options) {

// check if port is valid
let portIsValid = true;
if (options && options.port && isNaN(parseInt(options.port))) {
portIsValid = false;
console.error(`[JARVIS] your specified port ("${options.port}") is invalid, falling back to 1337, please check it again :)`);
};

this.options = {
port: options && options.port || 1337 // if no port specified fall back to 1337
}
port: (options && portIsValid)
? parseInt(options.port)
: 1337 // fall back to 1337 if port is not a number
};
this.env = {
production: false,
running: false, // indicator if our express server + sockets are running
Expand All @@ -21,7 +31,7 @@ function Jarvis(options) {
};
}

Jarvis.prototype.apply = function (compiler) {
Jarvis.prototype.apply = function(compiler) {
let projectInfo = {
name: pkg.name,
version: pkg.version,
Expand Down

0 comments on commit f113d22

Please sign in to comment.