@@ -34,33 +34,14 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
3434 }
3535 }
3636
37- async initializeGitRepository ( ) {
38- try {
39- const git = this . createGit ( ) ;
40- if ( await git . checkIsRepo ( ) ) {
41- if ( await git . checkIsRepo ( 'root' as any ) ) {
42- this . log . info ( 'Using existing git repository.' ) ;
43- } else {
44- this . log . info ( 'Using existing git repository at parent folder.' ) ;
45- }
46- this . existingRepository = true ;
47- } else if ( await git . init ( ) ) {
48- this . log . ok ( 'Git repository initialized.' ) ;
49- }
50- this . gitInitialized = true ;
51- } catch ( error ) {
52- this . log . warn ( `Failed to initialize Git repository.\n ${ error } ` ) ;
53- }
54- }
55-
5637 get initializing ( ) {
5738 return this . asInitializingTaskGroup ( {
5839 async checkGit ( ) {
5940 if ( ! this . options . skipGit ) {
6041 const gitInstalled = ( await this . createGit ( ) . version ( ) ) . installed ;
6142 if ( ! gitInstalled ) {
6243 this . log . warn ( 'Git repository will not be created, as Git is not installed on your system' ) ;
63- this . options . skipGit = true ;
44+ this . gitInitialized = false ;
6445 }
6546 }
6647 } ,
@@ -127,7 +108,6 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
127108 this . log . debug ( 'Committing files to git' ) ;
128109 const git = this . createGit ( ) ;
129110 const repositoryRoot = await git . revparse ( [ '--show-toplevel' ] ) ;
130- const msg = await git . log ( [ '-n' , '1' ] ) . catch ( ( ) => ( { total : 0 } ) ) ;
131111 const result = await git . log ( [ '-n' , '1' , '--' , '.yo-rc.json' ] ) . catch ( ( ) => ( { total : 0 } ) ) ;
132112 const existingApplication = result . total > 0 ;
133113 if ( existingApplication && ! this . options . forceGit ) {
@@ -175,4 +155,23 @@ export default class GitGenerator extends BaseGenerator<GitConfig, GitOptions> {
175155 get [ BaseGenerator . END ] ( ) {
176156 return this . delegateTasksToBlueprint ( ( ) => this . end ) ;
177157 }
158+
159+ async initializeGitRepository ( ) {
160+ try {
161+ const git = this . createGit ( ) ;
162+ if ( await git . checkIsRepo ( ) ) {
163+ if ( await git . checkIsRepo ( 'root' as any ) ) {
164+ this . log . info ( 'Using existing git repository.' ) ;
165+ } else {
166+ this . log . info ( 'Using existing git repository at parent folder.' ) ;
167+ }
168+ this . existingRepository = true ;
169+ } else if ( await git . init ( ) ) {
170+ this . log . ok ( 'Git repository initialized.' ) ;
171+ }
172+ this . gitInitialized = true ;
173+ } catch ( error ) {
174+ this . log . warn ( `Failed to initialize Git repository.\n ${ error } ` ) ;
175+ }
176+ }
178177}
0 commit comments