File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
tests/integration/commands/deploy Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -586,6 +586,10 @@ const handleBuild = async ({
586
586
deployHandler,
587
587
} )
588
588
const { configMutations, exitCode, newConfig } = await runBuild ( resolvedOptions )
589
+ // Without this, the deploy command fails silently
590
+ if ( options . json && exitCode !== 0 ) {
591
+ logAndThrowError ( 'Error while running build' )
592
+ }
589
593
if ( exitCode !== 0 ) {
590
594
exit ( exitCode )
591
595
}
Original file line number Diff line number Diff line change @@ -449,6 +449,33 @@ describe.skipIf(process.env.NETLIFY_TEST_DISABLE_LIVE === 'true').concurrent('co
449
449
} )
450
450
} )
451
451
452
+ test ( 'should throw error when build fails with --json option' , async ( t ) => {
453
+ await withSiteBuilder ( t , async ( builder ) => {
454
+ builder
455
+ . withContentFile ( {
456
+ path : 'public/index.html' ,
457
+ content : '<h1>Test content</h1>' ,
458
+ } )
459
+ . withNetlifyToml ( {
460
+ config : {
461
+ build : {
462
+ publish : 'public' ,
463
+ command : 'exit 1' ,
464
+ } ,
465
+ } ,
466
+ } )
467
+
468
+ await builder . build ( )
469
+
470
+ await expect (
471
+ callCli ( [ 'deploy' , '--json' ] , {
472
+ cwd : builder . directory ,
473
+ env : { NETLIFY_SITE_ID : context . siteId } ,
474
+ } ) ,
475
+ ) . rejects . toThrow ( 'Error while running build' )
476
+ } )
477
+ } )
478
+
452
479
test ( 'should deploy hidden public folder but ignore hidden/__MACOSX files' , { retry : 3 } , async ( t ) => {
453
480
await withSiteBuilder ( t , async ( builder ) => {
454
481
builder
You can’t perform that action at this time.
0 commit comments