@@ -689,6 +689,31 @@ describe('the nyc cli', function () {
689689 files . should . include ( 'ignore.js' )
690690 files . should . not . include ( 'package.json' )
691691 files . should . not . include ( 'node_modules' )
692+ const includeTarget = path . resolve ( fixturesCLI , 'output' , 'ignore.js' )
693+ fs . readFileSync ( includeTarget , 'utf8' )
694+ . should . match ( / v a r c o v _ / )
695+ done ( )
696+ } )
697+ } )
698+
699+ it ( 'copies all files from <input> to <output> as well as those that have been instrumented' , function ( done ) {
700+ const args = [ bin , 'instrument' , '--complete-copy' , './nyc-config-js' , './output' ]
701+
702+ const proc = spawn ( process . execPath , args , {
703+ cwd : fixturesCLI ,
704+ env : env
705+ } )
706+
707+ proc . on ( 'close' , function ( code ) {
708+ code . should . equal ( 0 )
709+ const files = fs . readdirSync ( path . resolve ( fixturesCLI , './output' ) )
710+ files . should . include ( 'index.js' )
711+ files . should . include ( 'ignore.js' )
712+ files . should . include ( 'package.json' )
713+ files . should . include ( 'node_modules' )
714+ const includeTarget = path . resolve ( fixturesCLI , 'output' , 'ignore.js' )
715+ fs . readFileSync ( includeTarget , 'utf8' )
716+ . should . match ( / v a r c o v _ / )
692717 done ( )
693718 } )
694719 } )
@@ -738,19 +763,22 @@ describe('the nyc cli', function () {
738763 code . should . equal ( 0 )
739764 const files = fs . readdirSync ( path . resolve ( fixturesCLI , './output' ) )
740765 files . length . should . not . equal ( 0 )
741- files . should . not . include ( 'exclude-me' )
742- files . should . not . include ( 'node_modules' )
766+ files . should . include ( 'exclude-me' )
767+ files . should . include ( 'node_modules' )
743768 files . should . include ( 'index.js' )
744769 files . should . include ( 'bad.js' )
745770 const includeTarget = path . resolve ( fixturesCLI , 'output' , 'index.js' )
746771 fs . readFileSync ( includeTarget , 'utf8' )
747772 . should . match ( / v a r c o v _ / )
773+ const excludeTarget = path . resolve ( fixturesCLI , 'output' , 'exclude-me' , 'index.js' )
774+ fs . readFileSync ( excludeTarget , 'utf8' )
775+ . should . not . match ( / v a r c o v _ / )
748776 done ( )
749777 } )
750778 } )
751779
752780 it ( 'allows a file to be excluded' , function ( done ) {
753- const args = [ bin , 'instrument' , '--exclude' , 'exclude-me/index.js' , './subdir/input-dir' , './output' ]
781+ const args = [ bin , 'instrument' , '--complete-copy' , '-- exclude', 'exclude-me/index.js' , './subdir/input-dir' , './output' ]
754782
755783 const proc = spawn ( process . execPath , args , {
756784 cwd : fixturesCLI ,
@@ -761,7 +789,10 @@ describe('the nyc cli', function () {
761789 code . should . equal ( 0 )
762790 const files = fs . readdirSync ( path . resolve ( fixturesCLI , './output' ) )
763791 files . length . should . not . equal ( 0 )
764- files . should . not . include ( 'exclude-me' )
792+ files . should . include ( 'exclude-me' )
793+ const excludeTarget = path . resolve ( fixturesCLI , 'output' , 'exclude-me' , 'index.js' )
794+ fs . readFileSync ( excludeTarget , 'utf8' )
795+ . should . not . match ( / v a r c o v _ / )
765796 done ( )
766797 } )
767798 } )
@@ -787,7 +818,7 @@ describe('the nyc cli', function () {
787818 } )
788819
789820 it ( 'allows a file to be excluded from an included directory' , function ( done ) {
790- const args = [ bin , 'instrument' , '--exclude' , '**/exclude-me.js' , '--include' , '**/include-me/**' , './subdir/input-dir' , './output' ]
821+ const args = [ bin , 'instrument' , '--complete-copy' , '-- exclude', '**/exclude-me.js' , '--include' , '**/include-me/**' , './subdir/input-dir' , './output' ]
791822
792823 const proc = spawn ( process . execPath , args , {
793824 cwd : fixturesCLI ,
@@ -802,10 +833,13 @@ describe('the nyc cli', function () {
802833 const includeMeFiles = fs . readdirSync ( path . resolve ( fixturesCLI , 'output' , 'include-me' ) )
803834 includeMeFiles . length . should . not . equal ( 0 )
804835 includeMeFiles . should . include ( 'include-me.js' )
805- includeMeFiles . should . not . include ( 'exclude-me.js' )
806- const instrumented = path . resolve ( fixturesCLI , 'output' , 'include-me' , 'include-me.js' )
807- fs . readFileSync ( instrumented , 'utf8' )
836+ includeMeFiles . should . include ( 'exclude-me.js' )
837+ const includeTarget = path . resolve ( fixturesCLI , 'output' , 'include-me' , 'include-me.js' )
838+ fs . readFileSync ( includeTarget , 'utf8' )
808839 . should . match ( / v a r c o v _ / )
840+ const excludeTarget = path . resolve ( fixturesCLI , 'output' , 'exclude-me' , 'index.js' )
841+ fs . readFileSync ( excludeTarget , 'utf8' )
842+ . should . not . match ( / v a r c o v _ / )
809843 done ( )
810844 } )
811845 } )
0 commit comments