@@ -689,6 +689,31 @@ describe('the nyc cli', function () {
689
689
files . should . include ( 'ignore.js' )
690
690
files . should . not . include ( 'package.json' )
691
691
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 _ / )
692
717
done ( )
693
718
} )
694
719
} )
@@ -738,19 +763,22 @@ describe('the nyc cli', function () {
738
763
code . should . equal ( 0 )
739
764
const files = fs . readdirSync ( path . resolve ( fixturesCLI , './output' ) )
740
765
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' )
743
768
files . should . include ( 'index.js' )
744
769
files . should . include ( 'bad.js' )
745
770
const includeTarget = path . resolve ( fixturesCLI , 'output' , 'index.js' )
746
771
fs . readFileSync ( includeTarget , 'utf8' )
747
772
. 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 _ / )
748
776
done ( )
749
777
} )
750
778
} )
751
779
752
780
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' ]
754
782
755
783
const proc = spawn ( process . execPath , args , {
756
784
cwd : fixturesCLI ,
@@ -761,7 +789,10 @@ describe('the nyc cli', function () {
761
789
code . should . equal ( 0 )
762
790
const files = fs . readdirSync ( path . resolve ( fixturesCLI , './output' ) )
763
791
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 _ / )
765
796
done ( )
766
797
} )
767
798
} )
@@ -787,7 +818,7 @@ describe('the nyc cli', function () {
787
818
} )
788
819
789
820
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' ]
791
822
792
823
const proc = spawn ( process . execPath , args , {
793
824
cwd : fixturesCLI ,
@@ -802,10 +833,13 @@ describe('the nyc cli', function () {
802
833
const includeMeFiles = fs . readdirSync ( path . resolve ( fixturesCLI , 'output' , 'include-me' ) )
803
834
includeMeFiles . length . should . not . equal ( 0 )
804
835
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' )
808
839
. 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 _ / )
809
843
done ( )
810
844
} )
811
845
} )
0 commit comments