Skip to content

Commit

Permalink
Bail out of launch script if no default $GOPATH exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfent committed Sep 17, 2017
1 parent 221edd9 commit cb8a619
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
12 changes: 10 additions & 2 deletions pokemon-showdown
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ if (config && config.golang) {
// to be able to handle Go dependencies. Since Go only cares about the
// first path in the list, so will we.
const GOPATH = child_process.execSync('go env GOPATH', {stdio: null, encoding: 'utf8'})
.trim().split(path.delimiter)[0];
.trim()
.split(path.delimiter)[0];
if (!GOPATH) {
// Should never happen, but it does on Bash on Ubuntu on Windows.
console.error('There is no $GOPATH environment variable set. Run:');
console.error('$ go help GOPATH');
console.error('For more information on how to configure it.');
process.exit(0);
}

const dependencies = ['github.com/gorilla/mux', 'github.com/igm/sockjs-go/sockjs'];
let packages = child_process.execSync('go list all', {stdio: null, encoding: 'utf8'});
Expand Down Expand Up @@ -101,7 +109,7 @@ if (config && config.golang) {
fs.mkdirSync(path.resolve(GOPATH, 'src/github.com/Zarel'));
fs.mkdirSync(path.resolve(GOPATH, 'src/github.com/Zarel/Pokemon-Showdown'));
} catch (e) {
console.log(e);
console.error(e);
console.error(`Cannot make go source directory for the sockets library files! Symlink them manually from ${srcPath} to ${tarPath}`);
process.exit(0);
}
Expand Down
11 changes: 8 additions & 3 deletions sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,15 @@ class GoWorker extends EventEmitter {
}

let message = (this.ibuf + data).slice(0, -1);
// FIXME: specific client messages are screwing with Go's JSON
// marshaller....
if (message.endsWith('\uFFFD')) message = message.slice(0, -1);
this.ibuf = '';

// FIXME: certain client messages are screwing with Go's JSON
// marshaller! Better not be a SockJS bug.
if (message.endsWith('\uFFFD')) {
Monitor.log(`Sockets: received a message from the client with malformed codepoints: ${message}`);
message = message.slice(0, -1);
}

this.emit('message', JSON.parse(message));
});
this.connection.on('error', () => {});
Expand Down

0 comments on commit cb8a619

Please sign in to comment.