@@ -791,4 +791,73 @@ process.on('message', (message) => {
791791 `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
792792 ] ) ;
793793 } ) ;
794+
795+ it ( 'should watch changes to a file from config file' , async ( ) => {
796+ const file = createTmpFile ( ) ;
797+ const configFile = createTmpFile ( JSON . stringify ( { watch : { 'watch' : true } } ) , '.json' ) ;
798+ const { stderr, stdout } = await runWriteSucceed ( {
799+ file, watchedFile : file , args : [ '--experimental-config-file' , configFile , file ] , options : {
800+ timeout : 10000
801+ }
802+ } ) ;
803+
804+ assert . strictEqual ( stderr , '' ) ;
805+ assert . deepStrictEqual ( stdout , [
806+ 'running' ,
807+ `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
808+ `Restarting ${ inspect ( file ) } ` ,
809+ 'running' ,
810+ `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
811+ ] ) ;
812+ } ) ;
813+
814+ it ( 'should watch changes to a file with watch-path from config file' , {
815+ skip : ! supportsRecursive ,
816+ } , async ( ) => {
817+ const dir = tmpdir . resolve ( 'subdir4' ) ;
818+ mkdirSync ( dir ) ;
819+ const file = createTmpFile ( ) ;
820+ const watchedFile = createTmpFile ( '' , '.js' , dir ) ;
821+ const configFile = createTmpFile ( JSON . stringify ( { watch : { 'watch-path' : [ dir ] } } ) , '.json' , dir ) ;
822+
823+ const args = [ '--experimental-config-file' , configFile , file ] ;
824+ const { stderr, stdout } = await runWriteSucceed ( { file, watchedFile, args } ) ;
825+
826+ assert . strictEqual ( stderr , '' ) ;
827+ assert . deepStrictEqual ( stdout , [
828+ 'running' ,
829+ `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
830+ `Restarting ${ inspect ( file ) } ` ,
831+ 'running' ,
832+ `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
833+ ] ) ;
834+ assert . strictEqual ( stderr , '' ) ;
835+ } ) ;
836+
837+ it ( 'should watch changes to a file from default config file' , async ( ) => {
838+ const dir = tmpdir . resolve ( 'subdir5' ) ;
839+ mkdirSync ( dir ) ;
840+
841+ const file = createTmpFile ( 'console.log("running");' , '.js' , dir ) ;
842+ writeFileSync ( path . join ( dir , 'node.config.json' ) , JSON . stringify ( { watch : { 'watch' : true } } ) ) ;
843+
844+ const { stderr, stdout } = await runWriteSucceed ( {
845+ file,
846+ watchedFile : file ,
847+ args : [ '--experimental-default-config-file' , file ] ,
848+ options : {
849+ timeout : 10000 ,
850+ cwd : dir
851+ }
852+ } ) ;
853+
854+ assert . strictEqual ( stderr , '' ) ;
855+ assert . deepStrictEqual ( stdout , [
856+ 'running' ,
857+ `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
858+ `Restarting ${ inspect ( file ) } ` ,
859+ 'running' ,
860+ `Completed running ${ inspect ( file ) } . Waiting for file changes before restarting...` ,
861+ ] ) ;
862+ } ) ;
794863} ) ;
0 commit comments