perf(plugins): list plugin dirs without per-entry statSync (#5690)
updatePlugins called fs.statSync on every entry returned by readdirSync just to test isDirectory(). Pass withFileTypes to readdirSync and filter on the Dirent type instead. Symlinks are still treated as directories.
This commit is contained in:
+4
-3
@@ -39,9 +39,10 @@ if (command === 'install') {
|
||||
}
|
||||
|
||||
async function updatePlugins() {
|
||||
const directories = fs.readdirSync(pluginsPath)
|
||||
.filter(file => !file.startsWith('.'))
|
||||
.filter(file => fs.statSync(path.join(pluginsPath, file)).isDirectory());
|
||||
const directories = fs.readdirSync(pluginsPath, { withFileTypes: true })
|
||||
.filter(dirent => dirent.isDirectory() || dirent.isSymbolicLink())
|
||||
.filter(dirent => !dirent.name.startsWith('.'))
|
||||
.map(dirent => dirent.name);
|
||||
|
||||
console.log(`Found ${color.cyan(directories.length)} directories in ./plugins`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user