@@ -42,10 +42,9 @@ export async function readFile(file: string) {
4242
4343export const unique = < T > ( array : T [ ] ) : T [ ] => [ ...new Set ( array ) ] ;
4444
45- async function gitAddFiles ( cwd : string ) {
45+ export async function removeFilesCannotAdd ( cwd : string , files : string [ ] = [ ] ) {
4646 try {
4747 await spawn ( "git" , [ "add" , "." ] , { cwd } ) ;
48- return ;
4948 } catch ( error ) {
5049 if ( error instanceof SubprocessError ) {
5150 const { stderr } = error ;
@@ -55,30 +54,25 @@ async function gitAddFiles(cwd: string) {
5554 const filename = match ?. groups ?. filename ;
5655 if ( filename ) {
5756 console . log ( `File '${ filename } ' can't be added, ignored.` ) ;
57+ files . push ( filename ) ;
5858 await fs . rm ( path . join ( cwd , filename ) , { force : true } ) ;
59- return gitAddFiles ( cwd ) ;
59+ return removeFilesCannotAdd ( cwd , files ) ;
6060 }
6161 }
6262
6363 throw error ;
6464 }
65+
66+ return files ;
6567}
6668
67- export const commitChanges = async (
68- directory : string ,
69- message : string ,
70- ignoreFilesCannotAdded ?: boolean ,
71- ) => {
69+ export const commitChanges = async ( directory : string , message : string ) => {
7270 await fs . rm ( path . join ( directory , ".gitattributes" ) , { force : true } ) ;
7371 await spawn ( "git" , [ "config" , "set" , "core.autocrlf" , "false" ] , {
7472 cwd : directory ,
7573 } ) ;
7674
77- if ( ignoreFilesCannotAdded ) {
78- await gitAddFiles ( directory ) ;
79- } else {
80- await spawn ( "git" , [ "add" , "." ] , { cwd : directory } ) ;
81- }
75+ await spawn ( "git" , [ "add" , "." ] , { cwd : directory } ) ;
8276
8377 await spawn (
8478 "git" ,
0 commit comments