@@ -61,15 +61,6 @@ exports.Server = function Server(bsClient, workers, config, callback) {
61
61
var filePath = path . relative ( process . cwd ( ) , filename ) ;
62
62
var pathMatches = ( testFilePaths . indexOf ( filePath ) !== - 1 ) ;
63
63
64
- var jsReportersPath = path . join ( __dirname , '../node_modules/js-reporters/dist/js-reporters.js' ) ;
65
- var jsReportersScript = fs . readFileSync ( jsReportersPath , {
66
- encoding : 'utf8'
67
- } ) ;
68
- var circularJSONPath = path . join ( __dirname , '../node_modules/circular-json/build/circular-json.js' ) ;
69
- var circularJSONScript = fs . readFileSync ( circularJSONPath , {
70
- encoding : 'utf8'
71
- } ) ;
72
-
73
64
if ( pathMatches ) {
74
65
var framework = config [ 'test_framework' ] ;
75
66
var tag_name = ( framework === 'mocha' ) ? 'head' : 'body' ;
@@ -79,8 +70,8 @@ exports.Server = function Server(bsClient, workers, config, callback) {
79
70
patch += '<script type="text/javascript" src="/_patch/' + script + '"></script>\n' ;
80
71
} ) ;
81
72
82
- patch += '<script type="text/javascript">' + jsReportersScript + '</script>' ;
83
- patch += '<script type="text/javascript">' + circularJSONScript + '</script>' ;
73
+ patch += externalScript ( '../node_modules/js-reporters/dist/js-reporters.js' ) ;
74
+ patch += externalScript ( '../node_modules/circular-json/build/circular-json.js' ) ;
84
75
85
76
// adding framework scripts
86
77
if ( framework === 'jasmine' ) {
@@ -203,7 +194,6 @@ exports.Server = function Server(bsClient, workers, config, callback) {
203
194
return config . test_path [ ++ worker . path_index ] ;
204
195
}
205
196
206
-
207
197
function getWorkerUuid ( request ) {
208
198
var uuid = request . headers [ 'x-worker-uuid' ] ;
209
199
@@ -229,6 +219,10 @@ exports.Server = function Server(bsClient, workers, config, callback) {
229
219
response . end ( ) ;
230
220
}
231
221
222
+ function externalScript ( scriptPath ) {
223
+ var scriptContents = fs . readFileSync ( path . join ( __dirname , scriptPath ) , { encoding : 'utf8' } ) ;
224
+ return '<script type="text/javascript">' + scriptContents + '</script>' ;
225
+ }
232
226
233
227
var handlers = {
234
228
'_progress' : function progressHandler ( uri , body , request , response ) {
0 commit comments