@@ -49,7 +49,7 @@ const sumanTestRegex = /'<suman-test>'/;
49
49
*/
50
50
51
51
const getTopHtml = function ( ) {
52
-
52
+
53
53
return [
54
54
'<!DOCTYPE html>' ,
55
55
'<html lang="en">' ,
@@ -70,9 +70,9 @@ const getBottomHtml = function () {
70
70
} ;
71
71
72
72
const getEmbeddedScript = function ( port : number , id : number , sumanConfigStr : string , sumanOptsStr : string ) {
73
-
73
+
74
74
const timestamp = Date . now ( ) ;
75
-
75
+
76
76
return [
77
77
'<script>' ,
78
78
`window.__suman = window.__suman || {};\n` ,
@@ -85,7 +85,7 @@ const getEmbeddedScript = function (port: number, id: number, sumanConfigStr: st
85
85
`window.__suman.sumanOpts=${ sumanOptsStr } ;\n` ,
86
86
'</script>'
87
87
] ;
88
-
88
+
89
89
} ;
90
90
91
91
const getSumanLibScript = function ( cb : Function ) {
@@ -96,68 +96,70 @@ const getSumanLibScript = function (cb: Function) {
96
96
if ( err ) {
97
97
return cb ( err ) ;
98
98
}
99
-
99
+
100
100
cb ( null , [
101
101
'<script>' ,
102
102
String ( data ) ,
103
103
'</script>'
104
104
] ) ;
105
-
105
+
106
106
} ) ;
107
107
} ;
108
108
109
109
const getWebpackBuild = function ( sumanHelperDir : string ) {
110
-
110
+
111
111
return function ( cb : Function ) {
112
-
112
+
113
113
let p = path . resolve ( sumanHelperDir + '/browser/builds/browser-tests.js' ) ;
114
-
114
+
115
115
fs . readFile ( p , 'utf8' , function ( err : Error , data : string ) {
116
116
if ( err ) {
117
117
return cb ( err ) ;
118
118
}
119
-
119
+
120
120
cb ( null , [
121
121
'<script>' ,
122
122
String ( data ) ,
123
123
'</script>'
124
124
] ) ;
125
-
125
+
126
126
} ) ;
127
127
}
128
128
} ;
129
129
130
130
export const makeGetBrowserStream = function ( sumanHelperDir : string , sumanConf : ISumanConfig , sumanOpts : ISumanOpts ) {
131
-
131
+
132
132
const sumanOptsStr = su . customStringify ( sumanOpts ) ;
133
133
const sumanConfigStr = su . customStringify ( sumanConf ) ;
134
-
134
+
135
135
return function getBrowserStream ( port : number , id : number , cb : Function ) {
136
-
136
+
137
137
async . parallel ( [
138
-
139
- getSumanLibScript ,
140
- getWebpackBuild ( sumanHelperDir )
141
-
142
- ] , function ( err : Error , results : any ) {
143
-
144
- if ( err ) {
145
- return cb ( err ) ;
146
- }
147
-
148
- // join all results together
149
- const all = < Array < Array < string > > > [
150
- getTopHtml ( ) ,
151
- getEmbeddedScript ( port , id , sumanConfigStr , sumanOptsStr ) ,
152
- results ,
153
- getBottomHtml ( )
154
- ] ;
155
-
156
- const allStr = _ . flattenDeep ( all . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ) ;
157
- cb ( null , allStr ) ;
158
-
159
- } )
160
-
138
+
139
+ getSumanLibScript ,
140
+ getWebpackBuild ( sumanHelperDir )
141
+
142
+ ] ,
143
+
144
+ function ( err : Error , results : any ) {
145
+
146
+ if ( err ) {
147
+ return cb ( err ) ;
148
+ }
149
+
150
+ // join all results together
151
+ const all = < Array < Array < string > > > [
152
+ getTopHtml ( ) ,
153
+ getEmbeddedScript ( port , id , sumanConfigStr , sumanOptsStr ) ,
154
+ results ,
155
+ getBottomHtml ( )
156
+ ] ;
157
+
158
+ const allStr = _ . flattenDeep ( all . reduce ( ( a , b ) => a . concat ( b ) , [ ] ) ) ;
159
+ cb ( null , allStr ) ;
160
+
161
+ } )
162
+
161
163
}
162
-
164
+
163
165
} ;
0 commit comments