MCPcopy Create free account
hub / github.com/anomalyco/opencode / externalCommandDirectories

Function externalCommandDirectories

packages/core/src/tool/bash.ts:81–91  ·  view source on GitHub ↗
(command: string, cwd: string)

Source from the content-addressed store, hash-verified

79const shellTokens = (command: string) => command.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) ?? []
80const unquote = (value: string) => value.replace(/^(['"])(.*)\1$/, "$2")
81const externalCommandDirectories = (command: string, cwd: string) => {
82 const directories = new Set<string>()
83 for (const token of shellTokens(command)) {
84 const value = unquote(token).replace(/[;,|&]+$/, "")
85 if (!path.isAbsolute(value)) continue
86 const resolved = FSUtil.resolve(value)
87 if (FSUtil.contains(cwd, resolved)) continue
88 directories.add(FSUtil.resolve(path.dirname(resolved)))
89 }
90 return [...directories]
91}
92
93const layer = Layer.effectDiscard(
94 Effect.gen(function* () {

Callers 1

bash.tsFile · 0.85

Calls 3

shellTokensFunction · 0.85
unquoteFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected