1- import { availableTemplates , configs , TemplateNames } from "#src/templateConfigs/index" ;
1+ import { availableTemplates , TemplateNames } from "#src/templateConfigs/index" ;
22import { colors as c , success } from "#src/util/log" ;
33import chokidar from "chokidar" ;
44import { Option , program } from "commander" ;
55import fs from "fs" ;
6+ import ignore from "ignore" ;
67import * as process from "node:process" ;
78import path from "path" ;
89import { debuglog } from "util" ;
@@ -19,7 +20,10 @@ program
1920program . parse ( ) ;
2021const options : { source : string ; template : TemplateNames ; rm : boolean } = program . opts ( ) ;
2122
22- const config = configs [ options . template ] ;
23+ const alwaysIgnorePatterns = [ / ^ \. p a p i \/ m e t a d a t a .* / ] ;
24+
25+ const gitignoreContents = fs . readFileSync ( path . join ( options . source , ".gitignore" ) , "utf-8" ) ;
26+ const gitignoreIg = ignore ( ) . add ( gitignoreContents ) ;
2327
2428const watcher = chokidar . watch ( options . source , {
2529 persistent : true ,
@@ -28,9 +32,11 @@ const watcher = chokidar.watch(options.source, {
2832 ignored : ( updPath ) => {
2933 if ( updPath === options . source ) return false ;
3034 const relpath = path . relative ( options . source , updPath ) ;
31- const matched = config . backSyncPatterns . some ( ( pattern ) => pattern . test ( relpath ) ) ;
3235
33- return ! matched ;
36+ if ( alwaysIgnorePatterns . some ( ( pattern ) => pattern . test ( relpath ) ) ) return true ;
37+ if ( gitignoreIg . ignores ( relpath ) ) return true ;
38+
39+ return false ;
3440 } ,
3541} ) ;
3642
0 commit comments