Skip to content

Commit e903da0

Browse files
Add silent option to getFilesAbsolutePath to suppress error logs when reading shell config files
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 6a107de commit e903da0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

npm-app/src/project-files.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -589,21 +589,27 @@ function findKnowledgeFilesInDir(dir: string): Record<string, string> {
589589
return result
590590
}
591591

592-
export function getFilesAbsolutePath(filePaths: string[]) {
592+
export function getFilesAbsolutePath(
593+
filePaths: string[],
594+
options: { silent?: boolean } = {},
595+
) {
593596
const result: Record<string, string | null> = {}
594597
for (const filePath of filePaths) {
595598
try {
596599
const content = fs.readFileSync(filePath, 'utf8')
597600
result[filePath] = content
598601
} catch (error) {
599-
logger.error(
600-
{
601-
errorMessage: error instanceof Error ? error.message : String(error),
602-
errorStack: error instanceof Error ? error.stack : undefined,
603-
filePath,
604-
},
605-
'Error reading file by absolute path',
606-
)
602+
if (!options.silent) {
603+
logger.error(
604+
{
605+
errorMessage:
606+
error instanceof Error ? error.message : String(error),
607+
errorStack: error instanceof Error ? error.stack : undefined,
608+
filePath,
609+
},
610+
'Error reading file by absolute path',
611+
)
612+
}
607613
result[filePath] = null
608614
}
609615
}
@@ -627,7 +633,7 @@ const loadShellConfigFiles = () => {
627633
path.join(homeDir, '.zshrc'),
628634
path.join(homeDir, '.kshrc'),
629635
]
630-
const files = getFilesAbsolutePath(configFiles)
636+
const files = getFilesAbsolutePath(configFiles, { silent: true })
631637
return filterObject(files, (value) => value !== null) as Record<
632638
string,
633639
string

0 commit comments

Comments
 (0)