@@ -40,7 +40,7 @@ function insideMercurialRepository() {
40
40
}
41
41
}
42
42
43
- function gitInit ( ) {
43
+ function tryGitInit ( ) {
44
44
try {
45
45
execSync ( 'git --version' , { stdio : 'ignore' } ) ;
46
46
@@ -114,23 +114,22 @@ module.exports = function(
114
114
115
115
// Rename gitignore after the fact to prevent npm from renaming it to .npmignore
116
116
// See: https://github.com/npm/npm/issues/1862
117
- fs . move (
118
- path . join ( appPath , 'gitignore' ) ,
119
- path . join ( appPath , '.gitignore' ) ,
120
- [ ] ,
121
- err => {
122
- if ( err ) {
123
- // Append if there's already a `.gitignore` file there
124
- if ( err . code === 'EEXIST' ) {
125
- const data = fs . readFileSync ( path . join ( appPath , 'gitignore' ) ) ;
126
- fs . appendFileSync ( path . join ( appPath , '.gitignore' ) , data ) ;
127
- fs . unlinkSync ( path . join ( appPath , 'gitignore' ) ) ;
128
- } else {
129
- throw err ;
130
- }
131
- }
117
+ try {
118
+ fs . moveSync (
119
+ path . join ( appPath , 'gitignore' ) ,
120
+ path . join ( appPath , '.gitignore' ) ,
121
+ [ ]
122
+ ) ;
123
+ } catch ( err ) {
124
+ // Append if there's already a `.gitignore` file there
125
+ if ( err . code === 'EEXIST' ) {
126
+ const data = fs . readFileSync ( path . join ( appPath , 'gitignore' ) ) ;
127
+ fs . appendFileSync ( path . join ( appPath , '.gitignore' ) , data ) ;
128
+ fs . unlinkSync ( path . join ( appPath , 'gitignore' ) ) ;
129
+ } else {
130
+ throw err ;
132
131
}
133
- ) ;
132
+ }
134
133
135
134
let command ;
136
135
let args ;
@@ -173,8 +172,9 @@ module.exports = function(
173
172
}
174
173
}
175
174
176
- if ( gitInit ( ) ) {
177
- console . log ( 'Initialized git repository' ) ;
175
+ if ( tryGitInit ( ) ) {
176
+ console . log ( ) ;
177
+ console . log ( 'Initialized a git repository.' ) ;
178
178
}
179
179
180
180
// Display the most elegant way to cd.
0 commit comments