Files
klz-cables.com/.pnpm-store/v10/files/69/47037646e6379f244caa8754025cd9085c42c5e45e900830f0c84c782ff12dfe36a7b059c7e1371d71252999fcbf5c59ec830d6dc178be367c8c50f359135e
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

30 lines
1.1 KiB
Plaintext

import path from 'path';
class SourceFileFilter {
static EXTENSIONS = ['ts', 'tsx', 'js', 'jsx'];
// Will not be entered, except if explicitly asked for
// TODO: At some point we should infer these from .gitignore
static IGNORED_DIRECTORIES = ['node_modules', '.next', '.git'];
static isSourceFile(filePath) {
const ext = path.extname(filePath);
return SourceFileFilter.EXTENSIONS.map(cur => '.' + cur).includes(ext);
}
static shouldEnterDirectory(dirPath, srcPaths) {
const dirName = path.basename(dirPath);
if (SourceFileFilter.IGNORED_DIRECTORIES.includes(dirName)) {
return SourceFileFilter.isIgnoredDirectoryExplicitlyIncluded(dirPath, srcPaths);
}
return true;
}
static isIgnoredDirectoryExplicitlyIncluded(ignoredDirPath, srcPaths) {
return srcPaths.some(srcPath => SourceFileFilter.isWithinPath(srcPath, ignoredDirPath));
}
static isWithinPath(targetPath, basePath) {
const relativePath = path.relative(basePath, targetPath);
return relativePath === '' || !relativePath.startsWith('..');
}
}
export { SourceFileFilter as default };