refactor(core): remove acceptable shell terminology

This commit is contained in:
rekram1-node
2026-08-23 17:56:55 +00:00
committed by Hona
parent 8228b3093b
commit 51528c33e9
3 changed files with 11 additions and 11 deletions
@@ -3,7 +3,7 @@ import { onCleanup } from "solid-js"
export type ShellOption = {
path: string
name: string
acceptable: boolean
compatible: boolean
}
export type ShellSelectOption = {
@@ -27,7 +27,7 @@ export function createShellOptions(input: { shells: ShellOption[]; current: stri
id: shell.path,
value: ambiguous ? shell.path : shell.name,
name,
terminalOnly: !shell.acceptable,
terminalOnly: !shell.compatible,
}
}),
]
@@ -7,9 +7,9 @@ describe("settings controllers", () => {
expect(
createShellOptions({
shells: [
{ path: "/bin/bash", name: "bash", acceptable: true },
{ path: "/opt/bash", name: "bash", acceptable: false },
{ path: "/bin/zsh", name: "zsh", acceptable: true },
{ path: "/bin/bash", name: "bash", compatible: true },
{ path: "/opt/bash", name: "bash", compatible: false },
{ path: "/bin/zsh", name: "zsh", compatible: true },
],
current: "fish",
}),
+6 -6
View File
@@ -25,7 +25,7 @@ const META: Record<string, { deny?: boolean; login?: boolean; ps?: boolean }> =
export type Item = {
path: string
name: string
acceptable: boolean
compatible: boolean
}
export const Options = Schema.Struct({
@@ -74,7 +74,7 @@ function meta(file: string) {
return META[name(file)]
}
function ok(file: string) {
function compatible(file: string) {
return meta(file)?.deny !== true
}
@@ -112,8 +112,8 @@ async function unix() {
return ["/bin/bash", "/bin/zsh", "/bin/sh"]
}
function select(file: string | undefined, options?: Options, opts?: { acceptable?: boolean }, bin?: string) {
if (file && (!opts?.acceptable || ok(file))) {
function select(file: string | undefined, options?: Options, opts?: { compatible?: boolean }, bin?: string) {
if (file && (!opts?.compatible || compatible(file))) {
const shell = executable(file, options, bin)
if (shell) return shell
}
@@ -156,7 +156,7 @@ function info(file: string, options?: Options, bin?: string): Item {
return {
path: item,
name: executable(n, options, bin) ? n : item,
acceptable: ok(item),
compatible: compatible(item),
}
}
@@ -171,7 +171,7 @@ let defaultConfigured: { bin?: string; value: string } | undefined
let defaultCompatible: { bin?: string; value: string } | undefined
export function resolve(input: ResolveInput, configShell?: string, options?: Options, bin?: string) {
const filter = input.preference === "compatible" ? { acceptable: true } : undefined
const filter = input.preference === "compatible" ? { compatible: true } : undefined
if (configShell) return select(configShell, options, filter, bin)
if (options?.gitbash) return select(process.env.SHELL, options, filter, bin)
const cached = input.preference === "compatible" ? defaultCompatible : defaultConfigured