Skip to content

Commit

Permalink
duplicate same code when checking shell path
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftkey committed Jul 13, 2021
1 parent 43b24ec commit 722307d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/src/lib/shells/shared.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ChildProcess } from 'child_process'
import { pathExists } from 'fs-extra'
import { pathExists as pathExistsDefault } from 'fs-extra'

import * as Darwin from './darwin'
import * as Win32 from './win32'
import * as Linux from './linux'
import { pathExists as pathExistsLinux } from '../helpers/linux'
import { IFoundShell } from './found-shell'
import { ShellError } from './error'

Expand Down Expand Up @@ -72,6 +73,23 @@ export async function findShellOrDefault(shell: Shell): Promise<FoundShell> {
}
}

/**
* Use a platform-specific pathExists based on the platform, to simplify changes
* to the application logic
*
* @param path the location of some program on disk
*
* @returns `true` if the path exists on disk, or `false` otherwise
*
*/
function pathExists(path: string) {
if (__LINUX__) {
return pathExistsLinux(path)
} else {
return pathExistsDefault(path)
}
}

/** Launch the given shell at the path. */
export async function launchShell(
shell: FoundShell,
Expand Down

0 comments on commit 722307d

Please sign in to comment.