Есть функции:
function findFiles(folderPath) {
let files = []
folderPath = isAbsolute(folderPath) ? folderPath : join(process.cwd(), folderPath)
const folder = readdirSync(folderPath, { withFileTypes: true });
for (const file of folder) {
const pathFile = join(folderPath, file.name)
if (file.isDirectory()) {
files = [...files, ...findFiles(pathFile)]
continue
}
files.push(pathFile)
}
return files
}
function folderHandler(handlerPath, fn) {
for (const file of findFiles(handlerPath)) {
const { dir, base } = parse(file);
const props = require(file);
fn(props, base, parse(dir).name);
}
}
Как
const props = require(file)
переделать в `import ... from ...`?