MCPcopy Index your code
hub / github.com/isomorphic-git/isomorphic-git / read

Method read

src/models/FileSystem.js:117–137  ·  view source on GitHub ↗

* Return the contents of a file if it exists, otherwise returns null. * * @param {string} filepath - The path to the file. * @param {Object} [options] - Options for reading the file. * @returns {Promise } - The file contents, or `null` if the file doesn't exist.

(filepath, options = {})

Source from the content-addressed store, hash-verified

115 * @returns {Promise<Buffer|string|null>} - The file contents, or `null` if the file doesn't exist.
116 */
117 async read(filepath, options = {}) {
118 try {
119 let buffer = await this._readFile(filepath, options)
120 if (options.autocrlf === 'true') {
121 try {
122 buffer = new TextDecoder('utf8', { fatal: true }).decode(buffer)
123 buffer = buffer.replace(/\r\n/g, '\n')
124 buffer = new TextEncoder().encode(buffer)
125 } catch (error) {
126 // non utf8 file
127 }
128 }
129 // Convert plain ArrayBuffers to Buffers
130 if (typeof buffer !== 'string') {
131 buffer = Buffer.from(buffer)
132 }
133 return buffer
134 } catch (err) {
135 return null
136 }
137 }
138
139 /**
140 * Write a file (creating missing directories if need be) without throwing errors.

Callers 15

updateIndexFunction · 0.95
resetIndexFunction · 0.95
_commitFunction · 0.45
_fetchFunction · 0.45
_logFunction · 0.45
_indexPackFunction · 0.45
_isDescendentFunction · 0.45
listCommitsAndTagsFunction · 0.45
readObjectLooseFunction · 0.45
readObjectPackedFunction · 0.45
loadPackIndexFunction · 0.45
addToIndexFunction · 0.45

Calls 2

encodeMethod · 0.80
fromMethod · 0.45

Tested by 4

makeFixtureStashFunction · 0.36
stashChangesFunction · 0.36
makeFixtureStashFunction · 0.36
stashChangesFunction · 0.36