Skip to content

Commit 4a9d56f

Browse files
authored
Merge pull request atom#20899 from aminya/getAvailablePackages
Faster atom.packages.getAvailablePackages
2 parents d840b89 + d6cc11a commit 4a9d56f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/package-manager.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,17 @@ module.exports = class PackageManager {
419419

420420
for (const packageDirPath of this.packageDirPaths) {
421421
if (fs.isDirectorySync(packageDirPath)) {
422-
for (let packagePath of fs.readdirSync(packageDirPath)) {
423-
packagePath = path.join(packageDirPath, packagePath);
424-
const packageName = path.basename(packagePath);
422+
const packageNames = fs
423+
.readdirSync(packageDirPath, { withFileTypes: true })
424+
.filter(dirent => dirent.isDirectory())
425+
.map(dirent => dirent.name);
426+
427+
for (const packageName of packageNames) {
425428
if (
426429
!packageName.startsWith('.') &&
427-
!packagesByName.has(packageName) &&
428-
fs.isDirectorySync(packagePath)
430+
!packagesByName.has(packageName)
429431
) {
432+
const packagePath = path.join(packageDirPath, packageName);
430433
packages.push({
431434
name: packageName,
432435
path: packagePath,

0 commit comments

Comments
 (0)