mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Enhance download options and improve git error handling (#100)
* Fix download dialog to show gitignored paths with opt-in selection - Add getIgnoredPathsList API to detect gitignored files from git root - Fix git check-ignore to run from proper git root directory - Add ignored paths checkboxes in download dialog for opt-in inclusion - Support includeGit and includePaths options in download endpoints - Fix dialog button event handling to prevent page reload * Add clone timeout and improve git error handling * Refactor path extraction in download-zip endpoint
This commit is contained in:
1 parent
a02f7a2e98
commit
eccd49e877
12 files changed
+542
-121
No files matched your search
@@ -6,6 +6,7 @@ interface ExecuteCommandOptions {
|
||||
silent?: boolean
|
||||
env?: Record<string, string>
|
||||
ignoreExitCode?: boolean
|
||||
timeout?: number
|
||||
}
|
||||
|
||||
export async function executeCommand(
|
||||
@@ -45,6 +46,15 @@ export async function executeCommand(
|
||||
|
||||
let stdout = ''
|
||||
let stderr = ''
|
||||
let isResolved = false
|
||||
|
||||
const timeoutId = options.timeout ? setTimeout(() => {
|
||||
if (!isResolved) {
|
||||
isResolved = true
|
||||
proc.kill('SIGKILL')
|
||||
reject(new Error(`Command timed out after ${options.timeout}ms: ${args.join(' ')}`))
|
||||
}
|
||||
}, options.timeout) : undefined
|
||||
|
||||
proc.stdout?.on('data', (data: Buffer) => {
|
||||
stdout += data.toString()
|
||||
@@ -55,13 +65,22 @@ export async function executeCommand(
|
||||
})
|
||||
|
||||
proc.on('error', (error: Error) => {
|
||||
if (!options.silent) {
|
||||
logger.error(`Command failed: ${args.join(' ')}`, error)
|
||||
if (!isResolved) {
|
||||
isResolved = true
|
||||
if (timeoutId) clearTimeout(timeoutId)
|
||||
if (!options.silent) {
|
||||
logger.error(`Command failed: ${args.join(' ')}`, error)
|
||||
}
|
||||
reject(error)
|
||||
}
|
||||
reject(error)
|
||||
})
|
||||
|
||||
proc.on('close', (code: number | null) => {
|
||||
if (isResolved) return
|
||||
|
||||
isResolved = true
|
||||
if (timeoutId) clearTimeout(timeoutId)
|
||||
|
||||
if (options.ignoreExitCode) {
|
||||
resolve({ exitCode: code || 0, stdout, stderr })
|
||||
} else if (code === 0) {
|
||||
|
||||
Reference in new issue
Block a user