@@ -12,6 +12,7 @@ import {
1212 getProjectDirFromPackageName ,
1313 normalizeEditorOption ,
1414 renameFiles ,
15+ removeSrcOnlyTsconfigInclude ,
1516 shouldConfigureEditorsForCreate ,
1617} from '../utils.js' ;
1718
@@ -124,6 +125,61 @@ describe('deriveDefaultPackageName', () => {
124125 } ) ;
125126} ) ;
126127
128+ describe ( 'removeSrcOnlyTsconfigInclude' , ( ) => {
129+ let projectDir : string ;
130+
131+ beforeEach ( ( ) => {
132+ projectDir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'vp-tsconfig-include-' ) ) ;
133+ } ) ;
134+
135+ afterEach ( ( ) => {
136+ fs . rmSync ( projectDir , { recursive : true , force : true } ) ;
137+ } ) ;
138+
139+ function writeTsconfig ( tsconfig : unknown ) : void {
140+ fs . writeFileSync ( path . join ( projectDir , 'tsconfig.json' ) , JSON . stringify ( tsconfig , null , 2 ) ) ;
141+ }
142+
143+ function readTsconfig ( ) : Record < string , unknown > {
144+ return JSON . parse ( fs . readFileSync ( path . join ( projectDir , 'tsconfig.json' ) , 'utf-8' ) ) ;
145+ }
146+
147+ it ( 'removes the default src-only include' , ( ) => {
148+ writeTsconfig ( {
149+ compilerOptions : {
150+ strict : true ,
151+ } ,
152+ include : [ 'src' ] ,
153+ } ) ;
154+
155+ removeSrcOnlyTsconfigInclude ( projectDir ) ;
156+
157+ expect ( readTsconfig ( ) ) . toEqual ( {
158+ compilerOptions : {
159+ strict : true ,
160+ } ,
161+ } ) ;
162+ } ) ;
163+
164+ it ( 'keeps custom include patterns' , ( ) => {
165+ const tsconfig = {
166+ compilerOptions : {
167+ strict : true ,
168+ } ,
169+ include : [ 'src' , 'tests' ] ,
170+ } ;
171+ writeTsconfig ( tsconfig ) ;
172+
173+ removeSrcOnlyTsconfigInclude ( projectDir ) ;
174+
175+ expect ( readTsconfig ( ) ) . toEqual ( tsconfig ) ;
176+ } ) ;
177+
178+ it ( 'ignores projects without a tsconfig' , ( ) => {
179+ expect ( ( ) => removeSrcOnlyTsconfigInclude ( projectDir ) ) . not . toThrow ( ) ;
180+ } ) ;
181+ } ) ;
182+
127183describe ( 'ensureGitignoreNodeModules' , ( ) => {
128184 let projectDir : string ;
129185
0 commit comments