MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / walkDir

Function walkDir

javascript/selenium-webdriver/io/index.js:316–334  ·  view source on GitHub ↗

* Recursively walks a directory, returning a promise that will resolve with * a list of all files/directories seen. * * @param {string} rootPath the directory to walk. * @return {!Promise<!Array<{path: string, dir: boolean}>>} a promise that will * resolve with a list of entries seen. For e

(rootPath)

Source from the content-addressed store, hash-verified

314 * will be relative to `rootPath`.
315 */
316function walkDir(rootPath) {
317 const seen = []
318 return (function walk(dir) {
319 return checkedCall((callback) => fs.readdir(dir, callback)).then((files) =>
320 Promise.all(
321 files.map((file) => {
322 file = path.join(dir, file)
323 return checkedCall((cb) => fs.stat(file, cb)).then((stats) => {
324 seen.push({
325 path: path.relative(rootPath, file),
326 dir: stats.isDirectory(),
327 })
328 return stats.isDirectory() && walk(file)
329 })
330 }),
331 ),
332 )
333 })(rootPath).then(() => seen)
334}
335
336// PUBLIC API
337module.exports = {

Callers

nothing calls this directly

Calls 4

checkedCallFunction · 0.85
walkFunction · 0.85
isDirectoryMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected