@@ -487,7 +487,7 @@ describe("CLI integration", () => {
487487 expect ( errorOutput ) . not . toContain ( "Warning: dump output without --clean" ) ;
488488 } ) ;
489489
490- test ( "dump --build --no-warn-sensitive suppresses NODE_ENV label note " , ( ) => {
490+ test ( "dump --build warns when metadata environment label falls back to build NODE_ENV " , ( ) => {
491491 const configPath = path . join ( tempDir , "webpack.config.js" ) ;
492492 const buildConfig = path . join ( tempDir , "pack-config-diff-builds.yml" ) ;
493493
@@ -504,33 +504,109 @@ describe("CLI integration", () => {
504504 "utf8" ,
505505 ) ;
506506
507- const defaultCode = run ( [
507+ const code = run ( [ "dump" , "--build=dev" , `--config-file=${ buildConfig } ` , "--format=json" ] ) ;
508+
509+ expect ( code ) . toBe ( 0 ) ;
510+ const errorOutput = errorSpy . mock . calls . map ( ( args ) => String ( args [ 0 ] ) ) . join ( "\n" ) ;
511+ expect ( errorOutput ) . toContain ( 'Using build "dev" NODE_ENV="development" as dump environment' ) ;
512+ } ) ;
513+
514+ test ( "dump --build --no-warn-sensitive keeps NODE_ENV label note" , ( ) => {
515+ const configPath = path . join ( tempDir , "webpack.config.js" ) ;
516+ const buildConfig = path . join ( tempDir , "pack-config-diff-builds.yml" ) ;
517+
518+ fs . writeFileSync ( configPath , "module.exports = { mode: 'production' }\n" , "utf8" ) ;
519+ fs . writeFileSync (
520+ buildConfig ,
521+ [
522+ "builds:" ,
523+ " dev:" ,
524+ ` config: "${ configPath } "` ,
525+ " environment:" ,
526+ " NODE_ENV: development" ,
527+ ] . join ( "\n" ) ,
528+ "utf8" ,
529+ ) ;
530+
531+ const code = run ( [
508532 "dump" ,
509533 "--build=dev" ,
510534 `--config-file=${ buildConfig } ` ,
511535 "--format=json" ,
536+ "--no-warn-sensitive" ,
512537 ] ) ;
513538
514- expect ( defaultCode ) . toBe ( 0 ) ;
515- let errorOutput = errorSpy . mock . calls . map ( ( args ) => String ( args [ 0 ] ) ) . join ( "\n" ) ;
539+ expect ( code ) . toBe ( 0 ) ;
540+ const errorOutput = errorSpy . mock . calls . map ( ( args ) => String ( args [ 0 ] ) ) . join ( "\n" ) ;
516541 expect ( errorOutput ) . toContain ( 'Using build "dev" NODE_ENV="development" as dump environment' ) ;
542+ expect ( errorOutput ) . not . toContain ( "Warning: dump output without --clean" ) ;
543+ } ) ;
544+
545+ test ( "dump --build --no-warn-env-label suppresses NODE_ENV label note" , ( ) => {
546+ const configPath = path . join ( tempDir , "webpack.config.js" ) ;
547+ const buildConfig = path . join ( tempDir , "pack-config-diff-builds.yml" ) ;
548+
549+ fs . writeFileSync ( configPath , "module.exports = { mode: 'production' }\n" , "utf8" ) ;
550+ fs . writeFileSync (
551+ buildConfig ,
552+ [
553+ "builds:" ,
554+ " dev:" ,
555+ ` config: "${ configPath } "` ,
556+ " environment:" ,
557+ " NODE_ENV: development" ,
558+ ] . join ( "\n" ) ,
559+ "utf8" ,
560+ ) ;
561+
562+ const code = run ( [
563+ "dump" ,
564+ "--build=dev" ,
565+ `--config-file=${ buildConfig } ` ,
566+ "--format=json" ,
567+ "--no-warn-env-label" ,
568+ ] ) ;
517569
518- logSpy . mockClear ( ) ;
519- errorSpy . mockClear ( ) ;
570+ expect ( code ) . toBe ( 0 ) ;
571+ const errorOutput = errorSpy . mock . calls . map ( ( args ) => String ( args [ 0 ] ) ) . join ( "\n" ) ;
572+ expect ( errorOutput ) . not . toContain (
573+ 'Using build "dev" NODE_ENV="development" as dump environment' ,
574+ ) ;
575+ expect ( errorOutput ) . toContain ( "Warning: dump output without --clean" ) ;
576+ } ) ;
520577
521- const suppressedCode = run ( [
578+ test ( "dump --build --no-warn-sensitive --no-warn-env-label suppresses both warnings independently" , ( ) => {
579+ const configPath = path . join ( tempDir , "webpack.config.js" ) ;
580+ const buildConfig = path . join ( tempDir , "pack-config-diff-builds.yml" ) ;
581+
582+ fs . writeFileSync ( configPath , "module.exports = { mode: 'production' }\n" , "utf8" ) ;
583+ fs . writeFileSync (
584+ buildConfig ,
585+ [
586+ "builds:" ,
587+ " dev:" ,
588+ ` config: "${ configPath } "` ,
589+ " environment:" ,
590+ " NODE_ENV: development" ,
591+ ] . join ( "\n" ) ,
592+ "utf8" ,
593+ ) ;
594+
595+ const code = run ( [
522596 "dump" ,
523597 "--build=dev" ,
524598 `--config-file=${ buildConfig } ` ,
525599 "--format=json" ,
526600 "--no-warn-sensitive" ,
601+ "--no-warn-env-label" ,
527602 ] ) ;
528603
529- expect ( suppressedCode ) . toBe ( 0 ) ;
530- errorOutput = errorSpy . mock . calls . map ( ( args ) => String ( args [ 0 ] ) ) . join ( "\n" ) ;
604+ expect ( code ) . toBe ( 0 ) ;
605+ const errorOutput = errorSpy . mock . calls . map ( ( args ) => String ( args [ 0 ] ) ) . join ( "\n" ) ;
531606 expect ( errorOutput ) . not . toContain (
532607 'Using build "dev" NODE_ENV="development" as dump environment' ,
533608 ) ;
609+ expect ( errorOutput ) . not . toContain ( "Warning: dump output without --clean" ) ;
534610 } ) ;
535611
536612 test ( "dump --annotate injects inline docs for known keys" , ( ) => {
0 commit comments