code-pushup / cli

A CLI to run all kinds of code quality measurements to align your team with company goals
https://code-pushup.dev
MIT License
207 stars 11 forks source link

File helper improvements #350

Open BioPhoton opened 9 months ago

BioPhoton commented 9 months ago

The file helpers do not really scale at the moment.

The current API of the crawlFileSystem function looks like this:

export async function crawlFileSystem<T = string>(options: {
  directory: string;
  pattern?: string | RegExp; // file name pattern
  fileTransform?: (filePath: string) => Promise<T> | T;
}): Promise<T[]> {

}

API Improvements:

Logic improvements:

The potential API of the crawlFileSystem function looks like this:

export async function crawlFileSystem<T = string>(options: {
  file: (string | GlobPattern)[]; // file name pattern
  filterByContent?: (string | RegExp | (content: string) => boolean)[]; // file content pattern
}): Promise<T[]> {

}
vmasek commented 8 months ago

Lets threat this ticket as a research and refine separate issues for glob and file access.

Spike: 2md

BioPhoton commented 7 months ago
export async function crawlFileSystemAndLoad<T = string>(options: {
  file: ['**/tmp/**', '(search|test).component.ts', (path: string) => boolean ],
  // is Angular inline styles present
  content: [string | RegExp, (content: string) => boolean]
}) => Promise<T[]>
const filePaths =  await crawlFileSystem<T = string>({
  file: [(path: string) => boolean ],
  content: [(content: string) => boolean]
}): Promise<T[]> {

}

filePaths.map(loadFile)