Skip to content

Commit 34c0b6b

Browse files
author
Kerkesni
committed
rewrite extension index function
Issue: BB-585
1 parent c63df17 commit 34c0b6b

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

extensions/index.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ const path = require('path');
44
const extensions = {};
55

66
fs.readdirSync(__dirname).forEach(moduleDir => {
7-
const extStat = fs.statSync(path.join(__dirname, moduleDir));
8-
if (extStat.isDirectory()) {
9-
let indexStat;
10-
try {
11-
indexStat = fs.statSync(
12-
path.join(__dirname, moduleDir, 'index.js'));
13-
} catch {} // eslint-disable-line no-empty
14-
if (indexStat) {
15-
extensions[moduleDir] = require(`./${moduleDir}`);
16-
}
7+
const extPath = path.join(__dirname, moduleDir);
8+
const indexPath = path.join(extPath, 'index.js');
9+
10+
if (fs.statSync(extPath).isDirectory() &&
11+
fs.existsSync(indexPath)) {
12+
extensions[moduleDir] = require(`./${moduleDir}`);
1713
}
1814
});
1915

0 commit comments

Comments
 (0)