(originalPath, options)
| 1615 | } |
| 1616 | |
| 1617 | async function readdirRecursive(originalPath, options) { |
| 1618 | const result = []; |
| 1619 | const queue = [ |
| 1620 | [ |
| 1621 | originalPath, |
| 1622 | await PromisePrototypeThen( |
| 1623 | binding.readdir( |
| 1624 | originalPath, |
| 1625 | options.encoding, |
| 1626 | !!options.withFileTypes, |
| 1627 | kUsePromises, |
| 1628 | ), |
| 1629 | undefined, |
| 1630 | handleErrorFromBinding, |
| 1631 | ), |
| 1632 | ], |
| 1633 | ]; |
| 1634 | |
| 1635 | |
| 1636 | if (options.withFileTypes) { |
| 1637 | while (queue.length > 0) { |
| 1638 | // If we want to implement BFS make this a `shift` call instead of `pop` |
| 1639 | const { 0: path, 1: readdir } = ArrayPrototypePop(queue); |
| 1640 | for (const dirent of getDirents(path, readdir)) { |
| 1641 | ArrayPrototypePush(result, dirent); |
| 1642 | if (dirent.isDirectory()) { |
| 1643 | const direntPath = pathModule.join(path, dirent.name); |
| 1644 | ArrayPrototypePush(queue, [ |
| 1645 | direntPath, |
| 1646 | await PromisePrototypeThen( |
| 1647 | binding.readdir( |
| 1648 | direntPath, |
| 1649 | options.encoding, |
| 1650 | true, |
| 1651 | kUsePromises, |
| 1652 | ), |
| 1653 | undefined, |
| 1654 | handleErrorFromBinding, |
| 1655 | ), |
| 1656 | ]); |
| 1657 | } |
| 1658 | } |
| 1659 | } |
| 1660 | } else { |
| 1661 | while (queue.length > 0) { |
| 1662 | const { 0: path, 1: readdir } = ArrayPrototypePop(queue); |
| 1663 | for (const ent of readdir) { |
| 1664 | const direntPath = pathModule.join(path, ent); |
| 1665 | const stat = binding.internalModuleStat(direntPath); |
| 1666 | ArrayPrototypePush( |
| 1667 | result, |
| 1668 | pathModule.relative(originalPath, direntPath), |
| 1669 | ); |
| 1670 | if (stat === 1) { |
| 1671 | ArrayPrototypePush(queue, [ |
| 1672 | direntPath, |
| 1673 | await PromisePrototypeThen( |
| 1674 | binding.readdir( |
no test coverage detected
searching dependent graphs…