From 0c9d5f1920d0343b97c1fde4f2ffbcda10155543 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Thu, 29 Jun 2023 11:41:06 +0530 Subject: [PATCH] refactor: normalize file path to use unix slash when applying file filters --- package.json | 3 ++- src/files_manager.ts | 3 ++- tests/cli_parser.spec.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 23849f0..f253fda 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,8 @@ "fast-glob": "^3.2.12", "find-cache-dir": "^4.0.0", "getopts": "^2.3.0", - "ms": "^2.1.3" + "ms": "^2.1.3", + "slash": "^5.1.0" }, "directories": { "test": "test" diff --git a/src/files_manager.ts b/src/files_manager.ts index 16f17a7..9baac60 100644 --- a/src/files_manager.ts +++ b/src/files_manager.ts @@ -7,6 +7,7 @@ * file that was distributed with this source code. */ +import slash from 'slash' import { sep } from 'node:path' import fastGlob from 'fast-glob' import { pathToFileURL } from 'node:url' @@ -46,7 +47,7 @@ export class FilesManager { */ grep(files: URL[], filters: string[]): URL[] { return files.filter((file) => { - const filename = file.pathname + const filename = slash(file.pathname) const filenameWithoutTestSuffix = filename.replace(FILE_SUFFIX_EXPRESSION, '') return !!filters.find((filter) => { diff --git a/tests/cli_parser.spec.ts b/tests/cli_parser.spec.ts index 8f16fae..c0f2be5 100644 --- a/tests/cli_parser.spec.ts +++ b/tests/cli_parser.spec.ts @@ -121,7 +121,7 @@ const DATASET: [CLIArgs, CLIArgs][] = [ }, ], [ - new CliParser().parse(['--browser=chrome', '--browser=firefox']), + new CliParser().parse(['--browser', 'chrome', '--browser', 'firefox']), { '_': [] as string[], 'files': '',