barro
Version:
Flexible barrel file generation for Javascript and Typescript with watching built-in.
28 lines • 1.16 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findBarrelFiles = void 0;
const path_1 = require("path");
const globby_1 = __importDefault(require("globby"));
const getBarrelIgnoreGlobs_1 = require("./getBarrelIgnoreGlobs");
async function findBarrelFiles(barrel) {
const { match, matchDirectory } = barrel;
const relativePaths = await globby_1.default(match, {
cwd: matchDirectory,
ignore: getBarrelIgnoreGlobs_1.getBarrelIgnoreGlobs(barrel),
});
return relativePaths.map((relativePath) => {
const parsedPath = path_1.parse(relativePath);
return {
relativePath,
absolutePath: path_1.join(matchDirectory, relativePath),
// relative path without extension (most useful when generating index files)
path: path_1.join(parsedPath.dir, parsedPath.name),
name: parsedPath.name,
};
});
}
exports.findBarrelFiles = findBarrelFiles;
//# sourceMappingURL=findBarrelFiles.js.map