@@ -24,7 +24,8 @@ namespace ts {
24
24
"c:/dev/x/y/b.ts" ,
25
25
"c:/dev/js/a.js" ,
26
26
"c:/dev/js/b.js" ,
27
- "c:/ext/ext.ts"
27
+ "c:/ext/ext.ts" ,
28
+ "c:/ext/b/a..b.ts"
28
29
] ) ;
29
30
30
31
const caseSensitiveBasePath = "/dev/" ;
@@ -740,7 +741,7 @@ namespace ts {
740
741
"c:/dev/a.ts" ,
741
742
"c:/dev/b.ts" ,
742
743
"c:/dev/c.d.ts" ,
743
- "c:/ext/ext.ts" ,
744
+ "c:/ext/ext.ts"
744
745
] ,
745
746
wildcardDirectories : {
746
747
"c:/dev" : ts . WatchDirectoryFlags . None ,
@@ -752,6 +753,97 @@ namespace ts {
752
753
assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
753
754
assert . deepEqual ( actual . errors , expected . errors ) ;
754
755
} ) ;
756
+ it ( "include paths outside of the project using relative paths" , ( ) => {
757
+ const json = {
758
+ include : [
759
+ "*" ,
760
+ "../ext/*"
761
+ ] ,
762
+ exclude : [
763
+ "**"
764
+ ]
765
+ } ;
766
+ const expected : ts . ParsedCommandLine = {
767
+ options : { } ,
768
+ errors : [ ] ,
769
+ fileNames : [
770
+ "c:/ext/ext.ts"
771
+ ] ,
772
+ wildcardDirectories : {
773
+ "c:/ext" : ts . WatchDirectoryFlags . None
774
+ }
775
+ } ;
776
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
777
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
778
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
779
+ assert . deepEqual ( actual . errors , expected . errors ) ;
780
+ } ) ;
781
+ it ( "exclude paths outside of the project using relative paths" , ( ) => {
782
+ const json = {
783
+ include : [
784
+ "c:/**/*"
785
+ ] ,
786
+ exclude : [
787
+ "../**"
788
+ ]
789
+ } ;
790
+ const expected : ts . ParsedCommandLine = {
791
+ options : { } ,
792
+ errors : [ ] ,
793
+ fileNames : [ ] ,
794
+ wildcardDirectories : { }
795
+ } ;
796
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
797
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
798
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
799
+ assert . deepEqual ( actual . errors , expected . errors ) ;
800
+ } ) ;
801
+ it ( "include files with .. in their name" , ( ) => {
802
+ const json = {
803
+ include : [
804
+ "c:/ext/b/a..b.ts"
805
+ ] ,
806
+ exclude : [
807
+ "**"
808
+ ]
809
+ } ;
810
+ const expected : ts . ParsedCommandLine = {
811
+ options : { } ,
812
+ errors : [ ] ,
813
+ fileNames : [
814
+ "c:/ext/b/a..b.ts"
815
+ ] ,
816
+ wildcardDirectories : { }
817
+ } ;
818
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
819
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
820
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
821
+ assert . deepEqual ( actual . errors , expected . errors ) ;
822
+ } ) ;
823
+ it ( "exclude files with .. in their name" , ( ) => {
824
+ const json = {
825
+ include : [
826
+ "c:/ext/**/*"
827
+ ] ,
828
+ exclude : [
829
+ "c:/ext/b/a..b.ts"
830
+ ]
831
+ } ;
832
+ const expected : ts . ParsedCommandLine = {
833
+ options : { } ,
834
+ errors : [ ] ,
835
+ fileNames : [
836
+ "c:/ext/ext.ts" ,
837
+ ] ,
838
+ wildcardDirectories : {
839
+ "c:/ext" : ts . WatchDirectoryFlags . Recursive
840
+ }
841
+ } ;
842
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
843
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
844
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
845
+ assert . deepEqual ( actual . errors , expected . errors ) ;
846
+ } ) ;
755
847
it ( "with jsx=none, allowJs=false" , ( ) => {
756
848
const json = {
757
849
compilerOptions : {
@@ -951,6 +1043,108 @@ namespace ts {
951
1043
assert . deepEqual ( actual . errors , expected . errors ) ;
952
1044
} ) ;
953
1045
} ) ;
1046
+
1047
+ describe ( "with parent directory symbols after a recursive directory pattern" , ( ) => {
1048
+ it ( "in includes immediately after" , ( ) => {
1049
+ const json = {
1050
+ include : [
1051
+ "**/../*"
1052
+ ]
1053
+ } ;
1054
+ const expected : ts . ParsedCommandLine = {
1055
+ options : { } ,
1056
+ errors : [
1057
+ ts . createCompilerDiagnostic ( ts . Diagnostics . File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 , "**/../*" )
1058
+ ] ,
1059
+ fileNames : [ ] ,
1060
+ wildcardDirectories : { }
1061
+ } ;
1062
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
1063
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
1064
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
1065
+ assert . deepEqual ( actual . errors , expected . errors ) ;
1066
+ } ) ;
1067
+
1068
+ it ( "in includes after a subdirectory" , ( ) => {
1069
+ const json = {
1070
+ include : [
1071
+ "**/y/../*"
1072
+ ]
1073
+ } ;
1074
+ const expected : ts . ParsedCommandLine = {
1075
+ options : { } ,
1076
+ errors : [
1077
+ ts . createCompilerDiagnostic ( ts . Diagnostics . File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 , "**/y/../*" )
1078
+ ] ,
1079
+ fileNames : [ ] ,
1080
+ wildcardDirectories : { }
1081
+ } ;
1082
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
1083
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
1084
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
1085
+ assert . deepEqual ( actual . errors , expected . errors ) ;
1086
+ } ) ;
1087
+
1088
+ it ( "in excludes immediately after" , ( ) => {
1089
+ const json = {
1090
+ include : [
1091
+ "**/a.ts"
1092
+ ] ,
1093
+ exclude : [
1094
+ "**/.."
1095
+ ]
1096
+ } ;
1097
+ const expected : ts . ParsedCommandLine = {
1098
+ options : { } ,
1099
+ errors : [
1100
+ ts . createCompilerDiagnostic ( ts . Diagnostics . File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 , "**/.." )
1101
+ ] ,
1102
+ fileNames : [
1103
+ "c:/dev/a.ts" ,
1104
+ "c:/dev/x/a.ts" ,
1105
+ "c:/dev/x/y/a.ts" ,
1106
+ "c:/dev/z/a.ts"
1107
+ ] ,
1108
+ wildcardDirectories : {
1109
+ "c:/dev" : ts . WatchDirectoryFlags . Recursive
1110
+ }
1111
+ } ;
1112
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
1113
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
1114
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
1115
+ assert . deepEqual ( actual . errors , expected . errors ) ;
1116
+ } ) ;
1117
+
1118
+ it ( "in excludes after a subdirectory" , ( ) => {
1119
+ const json = {
1120
+ include : [
1121
+ "**/a.ts"
1122
+ ] ,
1123
+ exclude : [
1124
+ "**/y/.."
1125
+ ]
1126
+ } ;
1127
+ const expected : ts . ParsedCommandLine = {
1128
+ options : { } ,
1129
+ errors : [
1130
+ ts . createCompilerDiagnostic ( ts . Diagnostics . File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0 , "**/y/.." )
1131
+ ] ,
1132
+ fileNames : [
1133
+ "c:/dev/a.ts" ,
1134
+ "c:/dev/x/a.ts" ,
1135
+ "c:/dev/x/y/a.ts" ,
1136
+ "c:/dev/z/a.ts"
1137
+ ] ,
1138
+ wildcardDirectories : {
1139
+ "c:/dev" : ts . WatchDirectoryFlags . Recursive
1140
+ }
1141
+ } ;
1142
+ const actual = ts . parseJsonConfigFileContent ( json , caseInsensitiveHost , caseInsensitiveBasePath ) ;
1143
+ assert . deepEqual ( actual . fileNames , expected . fileNames ) ;
1144
+ assert . deepEqual ( actual . wildcardDirectories , expected . wildcardDirectories ) ;
1145
+ assert . deepEqual ( actual . errors , expected . errors ) ;
1146
+ } ) ;
1147
+ } ) ;
954
1148
} ) ;
955
1149
} ) ;
956
1150
}
0 commit comments