@@ -36,6 +36,8 @@ export class NextDeployInstance extends NextInstance {
3636 private _buildId : string
3737 private _deployId : string
3838 private _shouldDeleteDeploy : boolean = false
39+ private _isCurrentlyDeploying : boolean = false
40+ private _deployOutput : string = ''
3941
4042 public get buildId ( ) {
4143 // get deployment ID via fetch since we can't access
@@ -52,6 +54,8 @@ export class NextDeployInstance extends NextInstance {
5254 return
5355 }
5456
57+ this . _isCurrentlyDeploying = true
58+
5559 const setupStartTime = Date . now ( )
5660
5761 // create the test site
@@ -131,7 +135,7 @@ export class NextDeployInstance extends NextInstance {
131135 : testName
132136 const deployAlias = 'vercel-next-e2e'
133137
134- const deployRes = await execa (
138+ const deployResPromise = execa (
135139 'npx' ,
136140 [ 'netlify' , 'deploy' , '--build' , '--message' , deployTitle ?? '' , '--alias' , deployAlias ] ,
137141 {
@@ -140,7 +144,18 @@ export class NextDeployInstance extends NextInstance {
140144 } ,
141145 )
142146
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+
143156 if ( deployRes . exitCode !== 0 ) {
157+ // clear deploy output to avoid printing it again in destroy()
158+ this . _deployOutput = ''
144159 throw new Error (
145160 `Failed to deploy project (${ deployRes . exitCode } ) ${ deployRes . stdout } ${ deployRes . stderr } ` ,
146161 )
@@ -168,7 +183,7 @@ export class NextDeployInstance extends NextInstance {
168183 require ( 'console' ) . log ( `Logs: ${ buildLogsUrl } ` )
169184 }
170185 } catch ( err ) {
171- console . error ( err )
186+ require ( ' console' ) . error ( err )
172187 throw new Error ( `Failed to parse deploy output: ${ deployRes . stdout } ` )
173188 }
174189
@@ -181,6 +196,8 @@ export class NextDeployInstance extends NextInstance {
181196
182197 require ( 'console' ) . log ( `Got buildId: ${ this . _buildId } ` )
183198 require ( 'console' ) . log ( `Setup time: ${ ( Date . now ( ) - setupStartTime ) / 1000.0 } s` )
199+
200+ this . _isCurrentlyDeploying = false
184201 }
185202
186203 public async destroy ( ) : Promise < void > {
@@ -205,6 +222,13 @@ export class NextDeployInstance extends NextInstance {
205222 }
206223 }
207224
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+
208232 await super . destroy ( )
209233 }
210234
0 commit comments