fix: execute git config commands synchronously

this fixes the following error I was running into:

error: could not lock config file .git/config: File exists
releases/v3
Michael Bianco 2023-05-17 19:33:16 -06:00
parent acd95e2b8f
commit 1607ac70d5
No known key found for this signature in database
GPG Key ID: E5E32D3B0D0B4261
1 changed files with 11 additions and 7 deletions

View File

@ -31,14 +31,18 @@ module.exports = new (class Git {
} }
} }
// use a self-invoking async function to await promises inside a constructor
// this avoids git config lock errors which are triggered when multiple `git config` commands are run
(async () => {
// Set config // Set config
this.config('user.name', gitUserName) await this.config('user.name', gitUserName)
this.config('user.email', gitUserEmail) await this.config('user.email', gitUserEmail)
// Update the origin // Update the origin
if (githubToken) { if (githubToken) {
this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`) await this.updateOrigin(`https://x-access-token:${githubToken}@${gitUrl}/${GITHUB_REPOSITORY}.git`)
} }
})()
} }
/** /**