mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-22 04:17:20 +00:00
18 lines
607 B
JavaScript
18 lines
607 B
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const path = require("path");
|
|
const fs = require("fs");
|
|
|
|
// Helper function to map recursively over files in a folder and it's subfolders
|
|
module.exports.mapFiles = function mapFiles(startPath, filter, mapFunc) {
|
|
const files = fs.readdirSync(startPath);
|
|
for (let i = 0; i < files.length; i++) {
|
|
const filename = path.join(startPath, files[i]);
|
|
const stat = fs.lstatSync(filename);
|
|
if (stat.isDirectory()) {
|
|
mapFiles(filename, filter, mapFunc);
|
|
} else if (filename.indexOf(filter) >= 0) {
|
|
mapFunc(filename);
|
|
}
|
|
}
|
|
};
|