Merge pull request #20899 from aminya/getAvailablePackages

Faster atom.packages.getAvailablePackages
This commit is contained in:
Mazen Elkashef 2020-07-10 15:35:37 -05:00 committed by GitHub
commit 4a9d56f52c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -419,14 +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 packageNames = fs
.readdirSync(packageDirPath, { withFileTypes: true })
.filter(dirent => dirent.isDirectory())
.map(dirent => dirent.name);
for (const packageName of packageNames) {
if (
!packageName.startsWith('.') &&
!packagesByName.has(packageName) &&
fs.isDirectorySync(packagePath)
!packagesByName.has(packageName)
) {
const packagePath = path.join(packageDirPath, packageName);
packages.push({
name: packageName,
path: packagePath,