@@ -27,7 +27,13 @@ export function ensureSyncOutputWritable(outPath: string, force?: boolean): void
2727 }
2828}
2929
30- export async function syncCommand ( options : { file : string ; provider ?: string ; out ?: string ; force ?: boolean } ) {
30+ export async function syncCommand ( options : {
31+ file : string ;
32+ provider ?: string ;
33+ out ?: string ;
34+ force ?: boolean ;
35+ skipMissingFiles ?: boolean ;
36+ } ) {
3137 const outPath = options . out ?? DEFAULT_SYNC_OUTPUT ;
3238 ensureSyncOutputWritable ( outPath , options . force ) ;
3339
@@ -38,8 +44,10 @@ export async function syncCommand(options: { file: string; provider?: string; ou
3844
3945 const baseDir = dirname ( outPath ) ;
4046
41- // Interactive file path association (before writing yaml — skipped files are removed)
42- const removedFiles = await promptFileAssociation ( result . config , baseDir ) ;
47+ // File path association (before writing yaml — skipped files are removed)
48+ const removedFiles = options . skipMissingFiles
49+ ? removeMissingFileAssociations ( result . config , baseDir )
50+ : await promptFileAssociation ( result . config , baseDir ) ;
4351 if ( removedFiles . length > 0 ) {
4452 const files = ( result . config . files ?? { } ) as Record < string , unknown > ;
4553 for ( const key of removedFiles ) {
@@ -84,6 +92,19 @@ export async function syncCommand(options: { file: string; provider?: string; ou
8492 }
8593}
8694
95+ export function removeMissingFileAssociations ( config : Record < string , unknown > , baseDir : string ) : string [ ] {
96+ const files = ( config . files ?? { } ) as Record < string , Record < string , unknown > > ;
97+ const removed = Object . entries ( files )
98+ . filter ( ( [ , decl ] ) => ! fileExistsSync ( join ( baseDir , decl . source as string ) ) )
99+ . map ( ( [ key ] ) => key ) ;
100+
101+ if ( removed . length > 0 ) {
102+ log . info ( `${ removed . length } file(s) removed (skipped).` ) ;
103+ }
104+
105+ return removed ;
106+ }
107+
87108async function syncFromConfig (
88109 configPath : string ,
89110 explicitProvider ?: string ,
0 commit comments