This commit is contained in:
LukeParkerDev 2026-04-25 11:11:42 +10:00
parent 4f8ff6ab53
commit 341b8e78c9
2 changed files with 3 additions and 5 deletions

View file

@ -1,11 +1,8 @@
import { BashArity } from "@/permission/arity"
import { ShellKind } from "./id"
import type { ShellKind } from "./id"
export namespace ShellArity {
export function prefix(tokens: string[], shellType: ShellKind.ID) {
if (ShellKind.powershell(shellType) && tokens.length > 0 && /^[a-z]+-[a-z]+$/i.test(tokens[0])) {
return [tokens[0]]
}
export function prefix(tokens: string[], _shellType: ShellKind.ID) {
return BashArity.prefix(tokens)
}
}

View file

@ -36,4 +36,5 @@ test("powershell verb-noun structures", () => {
expect(ShellArity.prefix(["Get-Content", "file.txt"], "pwsh")).toEqual(["Get-Content"])
expect(ShellArity.prefix(["Remove-Item", "-Recurse", "dir"], "powershell")).toEqual(["Remove-Item"])
expect(ShellArity.prefix(["git", "checkout", "main"], "pwsh")).toEqual(["git", "checkout"])
expect(ShellArity.prefix(["redis-cli", "ping"], "pwsh")).toEqual(["redis-cli", "ping"])
})