extract method

This commit is contained in:
Simon Knott 2024-07-17 10:47:13 +02:00
parent 30447b14f4
commit 9123e1d9a1
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -80,13 +80,16 @@ export type TestFileFilter = {
column: number | null;
};
export async function createFileFiltersFromArguments(args: string[], onlyChanged: boolean): Promise<TestFileFilter[]> {
if (onlyChanged) {
const untrackedFiles = childProcess.execSync('git ls-files --others --exclude-standard', { encoding: 'utf-8' }).split('\n').filter(Boolean);
const changedFiles = childProcess.execSync('git diff --name-only', { encoding: 'utf-8' }).split('\n').filter(Boolean);
export async function detectChangedFiles(): Promise<string[]> {
const untrackedFiles = childProcess.execSync('git ls-files --others --exclude-standard', { encoding: 'utf-8' }).split('\n').filter(Boolean);
const changedFiles = childProcess.execSync('git diff --name-only', { encoding: 'utf-8' }).split('\n').filter(Boolean);
args = [...untrackedFiles, ...changedFiles];
}
return [...untrackedFiles, ...changedFiles];
}
export async function createFileFiltersFromArguments(args: string[], onlyChanged: boolean): Promise<TestFileFilter[]> {
if (onlyChanged)
args = await detectChangedFiles();
return args.map(arg => {
const match = /^(.*?):(\d+):?(\d+)?$/.exec(arg);