mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-17 12:56:41 +02:00
perms
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user