MCPcopy
hub / github.com/codeaashu/claude-code / detectLineEndings

Function detectLineEndings

src/utils/file.ts:120–135  ·  view source on GitHub ↗
(
  filePath: string,
  encoding: BufferEncoding = 'utf8',
)

Source from the content-addressed store, hash-verified

118}
119
120export function detectLineEndings(
121 filePath: string,
122 encoding: BufferEncoding = 'utf8',
123): LineEndingType {
124 try {
125 const fs = getFsImplementation()
126 const { resolvedPath } = safeResolvePath(fs, filePath)
127 const { buffer, bytesRead } = fs.readSync(resolvedPath, { length: 4096 })
128
129 const content = buffer.toString(encoding, 0, bytesRead)
130 return detectLineEndingsForString(content)
131 } catch (error) {
132 logError(error)
133 return 'LF'
134 }
135}
136
137export function convertLeadingTabsToSpaces(content: string): string {
138 // The /gm regex scans every line even on no-match; skip it entirely

Callers 1

applySedEditFunction · 0.85

Calls 5

getFsImplementationFunction · 0.85
safeResolvePathFunction · 0.85
logErrorFunction · 0.70
toStringMethod · 0.65

Tested by

no test coverage detected