mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-09 11:10:56 +00:00
perms
This commit is contained in:
parent
4f8ff6ab53
commit
341b8e78c9
2 changed files with 3 additions and 5 deletions
|
|
@ -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"])
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue