Skip to content

Commit

Permalink
- Implemented @darrachequesne's suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
a-lucas committed Jan 21, 2017
1 parent 5d3f51a commit 63c28c0
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,21 @@ Server.prototype.checkRequest = function(req, fn) {
Server.prototype.serveClient = function(v){
if (!arguments.length) return this._serveClient;
this._serveClient = v;

if (v && !clientSource) {

var clientSourcePath = path.resolve(__dirname, './../../socket.io-client/dist/socket.io.min.js');
var clientSourceMapPath = path.resolve(__dirname, './../../socket.io-client/dist/socket.io.min.js.map');
if(!exists(clientSourcePath)) {
clientSource = read(require.resolve('socket.io-client/dist/socket.io.min.js'), 'utf-8');
} else {
clientSource = read(clientSourcePath);
var resolvePath = function(file){
var filepath = path.resolve(__dirname, './../../', file);
if (exists(filepath)) {
return filepath;
}
if(!exists(clientSourceMapPath)) {
try {
clientSourceMap = read(require.resolve('socket.io-client/dist/socket.io.js.map'), 'utf-8');
} catch(err) {
debug('could not load sourcemap file');
}
} else {
clientSourceMap = read(clientSourceMapPath);
return require.resolve(file);
};
if (v && !clientSource) {
clientSource = read(resolvePath( 'socket.io-client/dist/socket.io.min.js'), 'utf-8');
try {
clientSourceMap = read(resolvePath( 'socket.io-client/dist/socket.io.min.js.map'), 'utf-8');
} catch(err) {
debug('could not load sourcemap file');
}
}

return this;
};

Expand Down

0 comments on commit 63c28c0

Please sign in to comment.