33const fs = require ( "fs-extra" ) ;
44const cp = require ( "child_process" ) ;
55const path = require ( 'path' ) ;
6- const parseGitConfig = require ( 'parse-git-config' ) ;
76
87const branchName = 'localization' ;
98const mergeTo = 'main' ;
@@ -105,8 +104,8 @@ cp.execSync('git fetch');
105104
106105// Remove old localization branch, if any
107106if ( hasBranch ( "localization" ) ) {
108- console . log ( `Remove old localization branch, if any (git branch -D localization)` ) ;
109- cp . execSync ( 'git branch -D localization' ) ;
107+ console . log ( `Remove old localization branch, if any (git branch -D localization)` ) ;
108+ cp . execSync ( 'git branch -D localization' ) ;
110109}
111110
112111// Check out local branch
@@ -128,13 +127,17 @@ if (!hasAnyChanges()) {
128127// Save existing user name and email, in case already set.
129128var existingUserName ;
130129var existingUserEmail ;
131- var gitConfigPath = path . resolve ( process . cwd ( ) , '../.git/config' ) ;
132- var config = parseGitConfig . sync ( { path : gitConfigPath } ) ;
133130
134- if ( typeof config === 'object' && config . hasOwnProperty ( 'user' ) ) {
135- existingUserName = config . user . name ;
136- existingUserEmail = config . user . email ;
131+ try {
132+ existingUserName = cp . execSync ( 'git config --local user.name' , { encoding : 'utf8' , cwd : process . cwd ( ) } ) . trim ( ) || undefined
133+ } catch {
134+ }
135+
136+ try {
137+ existingUserEmail = cp . execSync ( 'git config --local user.email' , { encoding : 'utf8' , cwd : process . cwd ( ) } ) . trim ( ) || undefined
138+ } catch {
137139}
140+
138141if ( existingUserName === undefined ) {
139142 console . log ( `Existing user name: undefined` ) ;
140143} else {
0 commit comments