Skip to content

Commit 808a682

Browse files
committed
🎨 cleanup
1 parent 5bc9ec5 commit 808a682

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

lib/git-process.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -226,32 +226,28 @@ export class GitProcess {
226226
{ cwd: path, encoding, maxBuffer, env, signal, killSignal },
227227
function (err, stdout, stderr) {
228228
const exitCode = typeof err?.code === 'number' ? err.code : 0
229-
if (!err || exitCode !== 0) {
229+
230+
if (!err || typeof err?.code === 'number') {
230231
resolve({ stdout, stderr, exitCode })
231232
return
232233
}
233234

234235
// If the error's code is a string then it means the code isn't the
235236
// process's exit code but rather an error coming from Node's bowels,
236237
// e.g., ENOENT.
237-
if (typeof err.code === 'string') {
238-
let { message, code } = err
239-
240-
if (err.code === 'ENOENT') {
241-
if (GitProcess.pathExists(path) === false) {
242-
message = 'Unable to find path to repository on disk.'
243-
code = RepositoryDoesNotExistErrorCode
244-
} else {
245-
message = `Git could not be found at the expected path: '${gitLocation}'. This might be a problem with how the application is packaged, so confirm this folder hasn't been removed when packaging.`
246-
code = GitNotFoundErrorCode
247-
}
238+
let { message, code } = err
239+
240+
if (err.code === 'ENOENT') {
241+
if (GitProcess.pathExists(path) === false) {
242+
message = 'Unable to find path to repository on disk.'
243+
code = RepositoryDoesNotExistErrorCode
244+
} else {
245+
message = `Git could not be found at the expected path: '${gitLocation}'. This might be a problem with how the application is packaged, so confirm this folder hasn't been removed when packaging.`
246+
code = GitNotFoundErrorCode
248247
}
249-
250-
reject(new ExecError(message, code, stdout, stderr, err))
251-
return
252248
}
253249

254-
reject(new ExecError(err.message, undefined, stdout, stderr, err))
250+
reject(new ExecError(message, code, stdout, stderr, err))
255251
}
256252
)
257253

@@ -345,7 +341,7 @@ function ignoreClosedInputStream({ stdin }: ChildProcess) {
345341
return
346342
}
347343

348-
stdin.on('error', err => {
344+
stdin.on('error', (err: unknown) => {
349345
const code = (err as ErrorWithCode).code
350346

351347
// Is the error one that we'd expect from the input stream being

0 commit comments

Comments
 (0)