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

Method readdirDeep

src/models/FileSystem.js:247–258  ·  view source on GitHub ↗

* Return a flat list of all the files nested inside a directory * * Based on an elegant concurrent recursive solution from SO * https://stackoverflow.com/a/45130990/2168416 * * @param {string} dir - The directory to read. * @returns {Promise } - A flat list of all files in

(dir)

Source from the content-addressed store, hash-verified

245 * @returns {Promise<string[]>} - A flat list of all files in the directory.
246 */
247 async readdirDeep(dir) {
248 const subdirs = await this._readdir(dir)
249 const files = await Promise.all(
250 subdirs.map(async subdir => {
251 const res = dir + '/' + subdir
252 return (await this._stat(res)).isDirectory()
253 ? this.readdirDeep(res)
254 : res
255 })
256 )
257 return files.reduce((a, f) => a.concat(f), [])
258 }
259
260 /**
261 * Return the Stats of a file/symlink if it exists, otherwise returns null.

Callers 3

listRefsMethod · 0.80
makeFixtureStashFunction · 0.80
makeFixtureStashFunction · 0.80

Calls

no outgoing calls

Tested by 2

makeFixtureStashFunction · 0.64
makeFixtureStashFunction · 0.64