@@ -36,6 +36,8 @@ export class NextDeployInstance extends NextInstance {
36
36
private _buildId : string
37
37
private _deployId : string
38
38
private _shouldDeleteDeploy : boolean = false
39
+ private _isCurrentlyDeploying : boolean = false
40
+ private _deployOutput : string = ''
39
41
40
42
public get buildId ( ) {
41
43
// get deployment ID via fetch since we can't access
@@ -52,6 +54,8 @@ export class NextDeployInstance extends NextInstance {
52
54
return
53
55
}
54
56
57
+ this . _isCurrentlyDeploying = true
58
+
55
59
const setupStartTime = Date . now ( )
56
60
57
61
// create the test site
@@ -131,7 +135,7 @@ export class NextDeployInstance extends NextInstance {
131
135
: testName
132
136
const deployAlias = 'vercel-next-e2e'
133
137
134
- const deployRes = await execa (
138
+ const deployResPromise = execa (
135
139
'npx' ,
136
140
[ 'netlify' , 'deploy' , '--build' , '--message' , deployTitle ?? '' , '--alias' , deployAlias ] ,
137
141
{
@@ -140,7 +144,18 @@ export class NextDeployInstance extends NextInstance {
140
144
} ,
141
145
)
142
146
147
+ const handleOutput = ( chunk ) => {
148
+ this . _deployOutput += chunk
149
+ }
150
+
151
+ deployResPromise . stdout . on ( 'data' , handleOutput )
152
+ deployResPromise . stderr . on ( 'data' , handleOutput )
153
+
154
+ const deployRes = await deployResPromise
155
+
143
156
if ( deployRes . exitCode !== 0 ) {
157
+ // clear deploy output to avoid printing it again in destroy()
158
+ this . _deployOutput = ''
144
159
throw new Error (
145
160
`Failed to deploy project (${ deployRes . exitCode } ) ${ deployRes . stdout } ${ deployRes . stderr } ` ,
146
161
)
@@ -168,7 +183,7 @@ export class NextDeployInstance extends NextInstance {
168
183
require ( 'console' ) . log ( `Logs: ${ buildLogsUrl } ` )
169
184
}
170
185
} catch ( err ) {
171
- console . error ( err )
186
+ require ( ' console' ) . error ( err )
172
187
throw new Error ( `Failed to parse deploy output: ${ deployRes . stdout } ` )
173
188
}
174
189
@@ -181,6 +196,8 @@ export class NextDeployInstance extends NextInstance {
181
196
182
197
require ( 'console' ) . log ( `Got buildId: ${ this . _buildId } ` )
183
198
require ( 'console' ) . log ( `Setup time: ${ ( Date . now ( ) - setupStartTime ) / 1000.0 } s` )
199
+
200
+ this . _isCurrentlyDeploying = false
184
201
}
185
202
186
203
public async destroy ( ) : Promise < void > {
@@ -205,6 +222,13 @@ export class NextDeployInstance extends NextInstance {
205
222
}
206
223
}
207
224
225
+ if ( this . _isCurrentlyDeploying ) {
226
+ require ( 'console' ) . log ( 'Destroying before deployment finished.' )
227
+ if ( this . _deployOutput ) {
228
+ require ( 'console' ) . log ( `Deploy logs so far:\n\n${ this . _deployOutput } \n\n` )
229
+ }
230
+ }
231
+
208
232
await super . destroy ( )
209
233
}
210
234
0 commit comments