using withFileTypes to filter out non-folders

no need to use path.basename
This commit is contained in:
Amin Yahyaabadi
2020-06-08 01:38:15 +00:00
parent fa4201a0a8
commit 35f18fd99d

View File

@@ -419,13 +419,17 @@ module.exports = class PackageManager {
for (const packageDirPath of this.packageDirPaths) {
if (fs.isDirectorySync(packageDirPath)) {
for (let packagePath of fs.readdirSync(packageDirPath)) {
packagePath = path.join(packageDirPath, packagePath);
const packageName = path.basename(packagePath);
const packagePaths = fs.readdirSync(packageDirPath, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
for (const packageName of packagePaths) {
if (
!packageName.startsWith('.') &&
!packagesByName.has(packageName)
) {
const packagePath = path.join(packageDirPath, packageName);
packages.push({
name: packageName,
path: packagePath,