From 9123e1d9a1a4f45cd184e2adf1d2ddc4a4f4f6a4 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 17 Jul 2024 10:47:13 +0200 Subject: [PATCH] extract method --- packages/playwright/src/util.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/playwright/src/util.ts b/packages/playwright/src/util.ts index 271dd60c92..a21b06c9b1 100644 --- a/packages/playwright/src/util.ts +++ b/packages/playwright/src/util.ts @@ -80,13 +80,16 @@ export type TestFileFilter = { column: number | null; }; -export async function createFileFiltersFromArguments(args: string[], onlyChanged: boolean): Promise { - 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 { + 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 { + if (onlyChanged) + args = await detectChangedFiles(); return args.map(arg => { const match = /^(.*?):(\d+):?(\d+)?$/.exec(arg);