@@ -98,27 +98,21 @@ Server.prototype.checkRequest = function(req, fn) {
9898Server . prototype . serveClient = function ( v ) {
9999 if ( ! arguments . length ) return this . _serveClient ;
100100 this . _serveClient = v ;
101-
102- if ( v && ! clientSource ) {
103-
104- var clientSourcePath = path . resolve ( __dirname , './../../socket.io-client/dist/socket.io.min.js' ) ;
105- var clientSourceMapPath = path . resolve ( __dirname , './../../socket.io-client/dist/socket.io.min.js.map' ) ;
106- if ( ! exists ( clientSourcePath ) ) {
107- clientSource = read ( require . resolve ( 'socket.io-client/dist/socket.io.min.js' ) , 'utf-8' ) ;
108- } else {
109- clientSource = read ( clientSourcePath ) ;
101+ var resolvePath = function ( file ) {
102+ var filepath = path . resolve ( __dirname , './../../' , file ) ;
103+ if ( exists ( filepath ) ) {
104+ return filepath ;
110105 }
111- if ( ! exists ( clientSourceMapPath ) ) {
112- try {
113- clientSourceMap = read ( require . resolve ( 'socket.io-client/dist/socket.io.js.map' ) , 'utf-8' ) ;
114- } catch ( err ) {
115- debug ( 'could not load sourcemap file' ) ;
116- }
117- } else {
118- clientSourceMap = read ( clientSourceMapPath ) ;
106+ return require . resolve ( file ) ;
107+ } ;
108+ if ( v && ! clientSource ) {
109+ clientSource = read ( resolvePath ( 'socket.io-client/dist/socket.io.min.js' ) , 'utf-8' ) ;
110+ try {
111+ clientSourceMap = read ( resolvePath ( 'socket.io-client/dist/socket.io.min.js' ) , 'utf-8' ) ;
112+ } catch ( err ) {
113+ debug ( 'could not load sourcemap file' ) ;
119114 }
120115 }
121-
122116 return this ;
123117} ;
124118
0 commit comments