MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / readlink

Method readlink

src/models/FileSystem.js:287–299  ·  view source on GitHub ↗

* Reads the contents of a symlink if it exists, otherwise returns null. * Rethrows errors that aren't related to file existence. * * @param {string} filename - The path to the symlink. * @param {Object} [opts={ encoding: 'buffer' }] - Options for reading the symlink. * @returns {Promi

(filename, opts = { encoding: 'buffer' })

Source from the content-addressed store, hash-verified

285 * @returns {Promise<Buffer|null>} - The symlink target, or `null` if it doesn't exist.
286 */
287 async readlink(filename, opts = { encoding: 'buffer' }) {
288 // Note: FileSystem.readlink returns a buffer by default
289 // so we can dump it into GitObject.write just like any other file.
290 try {
291 const link = await this._readlink(filename, opts)
292 return Buffer.isBuffer(link) ? link : Buffer.from(link)
293 } catch (err) {
294 if (err.code === 'ENOENT' || (err.code || '').includes('ENS')) {
295 return null
296 }
297 throw err
298 }
299 }
300
301 /**
302 * Write the contents of buffer to a symlink.

Callers 4

updateIndexFunction · 0.95
checkAndWriteBlobFunction · 0.80
addToIndexFunction · 0.80
contentMethod · 0.80

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected