Skip to content

Commit 97422ce

Browse files
Winget User Agreement
- Needs more testing but this is suppose to accept the user agreement and then install Git properly
1 parent e00d9a5 commit 97422ce

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,27 @@ app.on('ready', () => {
7575
*/
7676
});
7777

78+
const { exec } = require('child_process');
79+
7880
ipcMain.handle('install-git', async (event, args) => {
7981
return new Promise((resolve, reject) => {
80-
exec('winget install Git.Git', (error, stdout, stderr) => {
82+
const gitInstallationProcess = exec('winget install Git.Git', (error, stdout, stderr) => {
8183
if (error) {
8284
console.error(`Error executing git: ${error.message}`);
8385
reject(error.message);
8486
return;
8587
}
8688

8789
if (stderr) {
88-
console.error('Error during git command:', stderr);
89-
reject(stderr);
90-
return;
90+
// Check if stderr contains the agreement message
91+
if (stderr.includes("You must agree to the license terms before installing")) {
92+
// If agreement message is found, simulate pressing 'Enter'
93+
gitInstallationProcess.stdin.write('\r\n');
94+
} else {
95+
console.error('Error during git command:', stderr);
96+
reject(stderr);
97+
return;
98+
}
9199
} else {
92100
console.log('Git installed:', stdout.trim());
93101
resolve(stdout.trim());

0 commit comments

Comments
 (0)