* 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)
| 314 | * will be relative to `rootPath`. |
| 315 | */ |
| 316 | function 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 |
| 337 | module.exports = { |
nothing calls this directly
no test coverage detected