MCPcopy Index your code
hub / github.com/simstudioai/sim / replaceEnvVarsAsync

Function replaceEnvVarsAsync

apps/sim/executor/variables/resolver.ts:95–110  ·  view source on GitHub ↗
(
  template: string,
  replacer: (match: string) => Promise<string>
)

Source from the content-addressed store, hash-verified

93}
94
95async function replaceEnvVarsAsync(
96 template: string,
97 replacer: (match: string) => Promise<string>
98): Promise<string> {
99 const pattern = createEnvVarPattern()
100 let cursor = 0
101 let result = ''
102 for (const match of template.matchAll(pattern)) {
103 const fullMatch = match[0]
104 const index = match.index ?? 0
105 result += template.slice(cursor, index)
106 result += await replacer(fullMatch)
107 cursor = index + fullMatch.length
108 }
109 return result + template.slice(cursor)
110}
111
112type ShellQuoteContext = 'single' | 'double' | null
113type CodeStringQuoteContext = ShellQuoteContext | 'triple-single' | 'triple-double' | 'template'

Calls 1

createEnvVarPatternFunction · 0.90

Tested by

no test coverage detected