mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-01 03:12:42 +01:00
tests: Avoid deprecated fs.existsSync()
This commit is contained in:
parent
ab824c728f
commit
1b7b96f57e
1 changed files with 8 additions and 6 deletions
|
@ -1,8 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fsp = require('fs').promises;
|
||||||
const fsp = fs.promises;
|
|
||||||
const sanitizePathname = require('../../utils/sanitizePathname');
|
const sanitizePathname = require('../../utils/sanitizePathname');
|
||||||
const settings = require('../../utils/Settings');
|
const settings = require('../../utils/Settings');
|
||||||
|
|
||||||
|
@ -58,10 +57,13 @@ const getPluginTests = async (callback) => {
|
||||||
const specPath = 'static/tests/frontend/specs';
|
const specPath = 'static/tests/frontend/specs';
|
||||||
const plugins = await fsp.readdir(moduleDir);
|
const plugins = await fsp.readdir(moduleDir);
|
||||||
const specLists = await Promise.all(plugins.map(async (plugin) => {
|
const specLists = await Promise.all(plugins.map(async (plugin) => {
|
||||||
const specDir = path.join(moduleDir, plugin, specPath);
|
try {
|
||||||
if (!fs.existsSync(specDir)) return [];
|
const specs = await fsp.readdir(path.join(moduleDir, plugin, specPath));
|
||||||
const specFiles = await fsp.readdir(specDir);
|
return specs.map((spec) => `/static/plugins/${plugin}/${specPath}/${spec}`);
|
||||||
return specFiles.map((spec) => `/static/plugins/${plugin}/${specPath}/${spec}`);
|
} catch (err) {
|
||||||
|
if (['ENOENT', 'ENOTDIR'].includes(err.code)) return [];
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
return [].concat(...specLists);
|
return [].concat(...specLists);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue