mirror of
https://github.com/stablyai/orca.git
synced 2026-10-23 16:03:49 +00:00
fix: append ssh include lines without spread
This commit is contained in:
@@ -64,7 +64,7 @@ function expandSshConfigFile(
|
||||
|
||||
for (const includeArg of includeArgs) {
|
||||
for (const matchedPath of resolveIncludePaths(includeArg, context)) {
|
||||
expandedLines.push(...expandSshConfigFile(matchedPath, context, nextStack))
|
||||
appendExpandedLines(expandedLines, expandSshConfigFile(matchedPath, context, nextStack))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,14 @@ function expandSshConfigFile(
|
||||
return expandedLines
|
||||
}
|
||||
|
||||
function appendExpandedLines(target: string[], source: string[]): void {
|
||||
// Why: valid include files can stay under the byte cap while still exceeding
|
||||
// V8's argument limit if appended with `push(...source)`.
|
||||
for (const line of source) {
|
||||
target.push(line)
|
||||
}
|
||||
}
|
||||
|
||||
function readCachedFile(filePath: string, context: IncludeExpansionContext): string | null {
|
||||
const cached = context.cache.get(filePath)
|
||||
if (cached !== undefined) {
|
||||
|
||||
@@ -100,6 +100,19 @@ describe('loadUserSshConfig', () => {
|
||||
expect(loadUserSshConfig().map((host) => host.host)).toEqual(['first', 'second'])
|
||||
})
|
||||
|
||||
it('loads an include file with more lines than the JavaScript argument limit', () => {
|
||||
const home = makeHome()
|
||||
const manyCommentLines = Array.from({ length: 130_000 }, () => '#').join('\n')
|
||||
writeFile(
|
||||
home,
|
||||
'.ssh/config',
|
||||
'Include many-comments.conf\nHost after\n HostName after.example.com\n'
|
||||
)
|
||||
writeFile(home, '.ssh/many-comments.conf', manyCommentLines)
|
||||
|
||||
expect(loadUserSshConfig().map((host) => host.host)).toEqual(['after'])
|
||||
})
|
||||
|
||||
it('supports relative includes, ${VAR}, and local % tokens', () => {
|
||||
const home = makeHome()
|
||||
process.env.ORCA_SSH_INCLUDE = 'from-env.conf'
|
||||
|
||||
Reference in New Issue
Block a user