@zgeoff/rig 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/rig",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Run every test lane of a repo from one declaration of its limits, with a browser lane built in",
5
5
  "keywords": [
6
6
  "bun",
@@ -1,23 +1,31 @@
1
1
  import { posix } from 'node:path';
2
2
 
3
- const benchFilePattern = /^(?:(?<folder>.*)\/)?bench\/[^/]+\.bench\.ts$/u;
4
-
5
- // A bench file sits in the `bench/` folder of a package, or of the root of a single-package repo.
3
+ // A bench file sits in the `bench/` folder of a package, or beside the module it measures under the
4
+ // package's `src/`. The root of a single-package repo counts as a package.
6
5
  export function collectBenchFiles(
7
6
  trackedFiles: readonly string[],
8
7
  isWorkspaceRepo: boolean,
9
8
  ): readonly string[] {
10
9
  const tracked = new Set(trackedFiles);
11
10
 
12
- return trackedFiles.filter((file) => {
13
- const match = benchFilePattern.exec(file);
11
+ return trackedFiles.filter(
12
+ (file) =>
13
+ file.endsWith('.bench.ts') &&
14
+ listPackageFolders(file).some((folder) =>
15
+ folder === '' ? !isWorkspaceRepo : tracked.has(posix.join(folder, 'package.json')),
16
+ ),
17
+ );
18
+ }
14
19
 
15
- if (match === null) {
16
- return false;
17
- }
20
+ // The folders that hold the file as a bench file if they are a package: the parent of the `bench/`
21
+ // folder the file sits in, and the parent of each `src/` folder above the file.
22
+ function listPackageFolders(file: string): readonly string[] {
23
+ const segments = file.split('/');
24
+ const parents = segments.slice(0, -1);
18
25
 
19
- const folder = match.groups?.['folder'] ?? '';
26
+ return parents.flatMap((segment, index) => {
27
+ const isBenchFolder = segment === 'bench' && index === parents.length - 1;
20
28
 
21
- return folder === '' ? !isWorkspaceRepo : tracked.has(posix.join(folder, 'package.json'));
29
+ return isBenchFolder || segment === 'src' ? [parents.slice(0, index).join('/')] : [];
22
30
  });
23
31
  }