From 6002f7ba01a6a9db439412f41e3be114a94de6f7 Mon Sep 17 00:00:00 2001 From: Tom Howard Date: Wed, 6 Sep 2023 10:19:48 +1000 Subject: [PATCH 1/2] fix for vitest benchmark files are not ignored fixes #33 vitest benchmark files are not ignored --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 4296c34..bca0696 100644 --- a/index.ts +++ b/index.ts @@ -29,7 +29,7 @@ if (typeScriptEnabled) { } const isRoute = (ext: string) => extensions.includes(ext); -const isTest = (name: string) => name.endsWith('.test') || name.endsWith('.spec'); +const isTest = (name: string) => name.endsWith('.test') || name.endsWith('.spec') || name.endsWith('.bench'); const isDeclaration = (name: string, ext: string) => ext === '.ts' && name.endsWith('.d'); function addRequestHandler( From 6c98d83733c1af635de8e4178b86c2003314fef6 Mon Sep 17 00:00:00 2001 From: Tom Howard Date: Wed, 6 Sep 2023 10:36:54 +1000 Subject: [PATCH 2/2] fix for vitest benchmark files are not ignored Updated readme and added test for #33 vitest benchmark files are not ignored --- README.md | 2 +- index.ts | 3 ++- test/regular-server/test-server/routes/index.bench.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 test/regular-server/test-server/routes/index.bench.ts diff --git a/README.md b/README.md index 2353ddc..e46b071 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ will result: Path params can also be prefixed with `:` E.g. `:id` instead of `[id]` -The plugin will ignore any `.test/spec.js` files when loading routes +The plugin will ignore any `.{test|spec|bench}.js` files when loading routes ## Install diff --git a/index.ts b/index.ts index bca0696..a4c98fb 100644 --- a/index.ts +++ b/index.ts @@ -29,7 +29,8 @@ if (typeScriptEnabled) { } const isRoute = (ext: string) => extensions.includes(ext); -const isTest = (name: string) => name.endsWith('.test') || name.endsWith('.spec') || name.endsWith('.bench'); +const isTest = (name: string) => + name.endsWith('.test') || name.endsWith('.spec') || name.endsWith('.bench'); const isDeclaration = (name: string, ext: string) => ext === '.ts' && name.endsWith('.d'); function addRequestHandler( diff --git a/test/regular-server/test-server/routes/index.bench.ts b/test/regular-server/test-server/routes/index.bench.ts new file mode 100644 index 0000000..7a11246 --- /dev/null +++ b/test/regular-server/test-server/routes/index.bench.ts @@ -0,0 +1 @@ +throw new Error('This bench file should be ignored');